From 151d32d22c14447bccbc5c81f3d06a6689b2f593 Mon Sep 17 00:00:00 2001 From: Ricardo Ardissone Date: Sun, 3 May 2020 20:42:18 -0300 Subject: [PATCH 1/4] nixos/hostapd: use CRDA Needed for regulatory compliance and unlocking some channels. --- nixos/modules/services/networking/hostapd.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/modules/services/networking/hostapd.nix b/nixos/modules/services/networking/hostapd.nix index 2915b54f05b4..fc6e4c77a9ae 100644 --- a/nixos/modules/services/networking/hostapd.nix +++ b/nixos/modules/services/networking/hostapd.nix @@ -164,6 +164,8 @@ in environment.systemPackages = [ pkgs.hostapd ]; + services.udev.packages = [ pkgs.crda ]; + systemd.services.hostapd = { description = "hostapd wireless AP"; From c09c0542311b5f31dc22364192565721d33c6db8 Mon Sep 17 00:00:00 2001 From: Ricardo Ardissone Date: Sun, 3 May 2020 22:38:43 -0300 Subject: [PATCH 2/4] nixos/hostapd: add countryCode option --- nixos/modules/services/networking/hostapd.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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"; From d6d04422433dc031be0f6271fc594d68f4b01405 Mon Sep 17 00:00:00 2001 From: Ricardo Ardissone Date: Sun, 3 May 2020 22:39:14 -0300 Subject: [PATCH 3/4] nixos/hostapd: add logLevel option --- nixos/modules/services/networking/hostapd.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/hostapd.nix b/nixos/modules/services/networking/hostapd.nix index f2434be24621..c11f5bab3d5c 100644 --- a/nixos/modules/services/networking/hostapd.nix +++ b/nixos/modules/services/networking/hostapd.nix @@ -24,9 +24,9 @@ let # logging (debug level) logger_syslog=-1 - logger_syslog_level=2 + logger_syslog_level=${toString cfg.logLevel} logger_stdout=-1 - logger_stdout_level=2 + logger_stdout_level=${toString cfg.logLevel} ctrl_interface=/run/hostapd ctrl_interface_group=${cfg.group} @@ -145,6 +145,19 @@ in ''; }; + logLevel = mkOption { + default = 2; + type = types.int; + description = '' + Levels (minimum value for logged events): + 0 = verbose debugging + 1 = debugging + 2 = informational messages + 3 = notification + 4 = warning + ''; + }; + countryCode = mkOption { default = null; example = "US"; From a55b736a655c1bf4dffe8ddb985aaa350e22b2dc Mon Sep 17 00:00:00 2001 From: Ricardo Ardissone Date: Mon, 4 May 2020 21:28:56 -0300 Subject: [PATCH 4/4] nixos/hostapd: conditionally enable ieee80211d --- nixos/modules/services/networking/hostapd.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/hostapd.nix b/nixos/modules/services/networking/hostapd.nix index c11f5bab3d5c..87e07509fefa 100644 --- a/nixos/modules/services/networking/hostapd.nix +++ b/nixos/modules/services/networking/hostapd.nix @@ -21,6 +21,7 @@ let hw_mode=${cfg.hwMode} channel=${toString cfg.channel} ${optionalString (cfg.countryCode != null) ''country_code=${cfg.countryCode}''} + ${optionalString (cfg.countryCode != null) ''ieee80211d=1''} # logging (debug level) logger_syslog=-1 @@ -167,7 +168,10 @@ in 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) + (dot11CountryString). + If set this enables IEEE 802.11d. This advertises the countryCode and + the set of allowed channels and transmit power levels based on the + regulatory limits. ''; };