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