1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5 kernelVersion = config.boot.kernelPackages.kernel.version;
6 linuxKernelMinVersion = "5.8";
7 kernelPatch = pkgs.kernelPatches.ath_regd_optional // {
8 extraConfig = ''
9 ATH_USER_REGD y
10 '';
11 };
12in
13{
14 options.networking.wireless.athUserRegulatoryDomain = mkOption {
15 default = false;
16 type = types.bool;
17 description = ''
18 If enabled, sets the ATH_USER_REGD kernel config switch to true to
19 disable the enforcement of EEPROM regulatory restrictions for ath
20 drivers. Requires at least Linux ${linuxKernelMinVersion}.
21 '';
22 };
23
24 config = mkIf config.networking.wireless.athUserRegulatoryDomain {
25 assertions = singleton {
26 assertion = lessThan 0 (builtins.compareVersions kernelVersion linuxKernelMinVersion);
27 message = "ATH_USER_REGD patch for kernels older than ${linuxKernelMinVersion} not ported yet!";
28 };
29 boot.kernelPatches = [ kernelPatch ];
30 };
31}