@@ -20,6 +20,7 @@ let
2020 ssid=${cfg.ssid}
2121 hw_mode=${cfg.hwMode}
2222 channel=${toString cfg.channel}
23+ ${optionalString (cfg.countryCode != null) ''country_code=${cfg.countryCode}''}
2324
2425 # logging (debug level)
2526 logger_syslog=-1
@@ -144,6 +145,19 @@ in
144145 '';
145146 };
146147
148+ countryCode = mkOption {
149+ default = null;
150+ example = "US";
151+ type = with types; nullOr str;
152+ description = ''
153+ Country code (ISO/IEC 3166-1). Used to set regulatory domain.
154+ Set as needed to indicate country in which device is operating.
155+ This can limit available channels and transmit power.
156+ These two octets are used as the first two octets of the Country String
157+ (dot11CountryString)
158+ '';
159+ };
160+
147161 extraConfig = mkOption {
148162 default = "";
149163 example = ''
@@ -164,7 +178,7 @@ in
164178
165179 environment.systemPackages = [ pkgs.hostapd ];
166180
167− services.udev.packages = [ pkgs.crda ];
181+ services.udev.packages = optional (cfg.countryCode != null) [ pkgs.crda ];
168182
169183 systemd.services.hostapd =
170184 { description = "hostapd wireless AP";