about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRicardo Ardissone <ricardo.ardissone@gmail.com>2020-05-03 22:38:43 -0300
committerRicardo Ardissone <ricardo.ardissone@gmail.com>2020-05-04 00:31:09 -0300
commitc09c0542311b5f31dc22364192565721d33c6db8 (patch)
tree48587203736ef7736238f1fb2bca80f81bee6d4d
parent151d32d22c14447bccbc5c81f3d06a6689b2f593 (diff)
downloadnixlib-c09c0542311b5f31dc22364192565721d33c6db8.tar
nixlib-c09c0542311b5f31dc22364192565721d33c6db8.tar.gz
nixlib-c09c0542311b5f31dc22364192565721d33c6db8.tar.bz2
nixlib-c09c0542311b5f31dc22364192565721d33c6db8.tar.lz
nixlib-c09c0542311b5f31dc22364192565721d33c6db8.tar.xz
nixlib-c09c0542311b5f31dc22364192565721d33c6db8.tar.zst
nixlib-c09c0542311b5f31dc22364192565721d33c6db8.zip
nixos/hostapd: add countryCode option
-rw-r--r--nixos/modules/services/networking/hostapd.nix16
1 files changed, 15 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/hostapd.nix b/nixos/modules/services/networking/hostapd.nix
index fc6e4c77a9ae..f2434be24621 100644
--- a/nixos/modules/services/networking/hostapd.nix
+++ b/nixos/modules/services/networking/hostapd.nix
@@ -20,6 +20,7 @@ let
     ssid=${cfg.ssid}
     hw_mode=${cfg.hwMode}
     channel=${toString cfg.channel}
+    ${optionalString (cfg.countryCode != null) ''country_code=${cfg.countryCode}''}
 
     # logging (debug level)
     logger_syslog=-1
@@ -144,6 +145,19 @@ in
         '';
       };
 
+      countryCode = mkOption {
+        default = null;
+        example = "US";
+        type = with types; nullOr str;
+        description = ''
+          Country code (ISO/IEC 3166-1). Used to set regulatory domain.
+          Set as needed to indicate country in which device is operating.
+          This can limit available channels and transmit power.
+          These two octets are used as the first two octets of the Country String
+          (dot11CountryString)
+        '';
+      };
+
       extraConfig = mkOption {
         default = "";
         example = ''
@@ -164,7 +178,7 @@ in
 
     environment.systemPackages =  [ pkgs.hostapd ];
 
-    services.udev.packages = [ pkgs.crda ];
+    services.udev.packages = optional (cfg.countryCode != null) [ pkgs.crda ];
 
     systemd.services.hostapd =
       { description = "hostapd wireless AP";