git.iko.soy/typeable/nixpkgs
on master help sign in
hostapd: rename extraCfg -> extraConfig, added asserts
commitae4a7f9351ae77d24fe72f88ee95cc56554528b4 authorJakob Gillich <jakob@gillich.me> dateSat 26 Dec 2015, 11:35 (11 years ago) parent5a2f054
2 files changed+26−23
nixos/modules/rename.nix+2 nixos/modules/services/networking/hostapd.nix+24−23
nixos/modules/rename.nix+2
@@ -75,6 +75,8 @@ with lib;
7575 # DNSCrypt-proxy
7676 (mkRenamedOptionModule [ "services" "dnscrypt-proxy" "port" ] [ "services" "dnscrypt-proxy" "localPort" ])
7777
78+ (mkRenamedOptionModule [ "services" "hostapd" "extraCfg" ] [ "services" "hostapd" "extraConfig" ])
79+
7880 # Options that are obsolete and have no replacement.
7981 (mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ])
8082 (mkRemovedOptionModule [ "programs" "bash" "enable" ])
nixos/modules/services/networking/hostapd.nix+24−23
@@ -2,21 +2,17 @@
22
33# TODO:
44#
5−# asserts
5+# asserts
66# ensure that the nl80211 module is loaded/compiled in the kernel
7−# hwMode must be a/b/g
8−# channel must be between 1 and 13 (maybe)
97# wpa_supplicant and hostapd on the same wireless interface doesn't make any sense
10−# perhaps an assertion that there is a dhcp server and a dns server on the IP address serviced by the hostapd?
118
129with lib;
1310
1411let
1512
1613 cfg = config.services.hostapd;
17−
18− configFile = pkgs.writeText "hostapd.conf"
19− ''
14+
15+ configFile = pkgs.writeText "hostapd.conf" ''
2016 interface=${cfg.interface}
2117 driver=${cfg.driver}
2218 ssid=${cfg.ssid}
@@ -37,8 +33,8 @@ let
3733 wpa_passphrase=${cfg.wpaPassphrase}
3834 '' else ""}
3935
40− ${cfg.extraCfg}
41− '' ;
36+ ${cfg.extraConfig}
37+ '' ;
4238
4339in
4440
@@ -65,9 +61,9 @@ in
6561
6662 interface = mkOption {
6763 default = "";
68− example = "wlan0";
64+ example = "wlp2s0";
6965 description = ''
70− The interfaces <command>hostapd</command> will use.
66+ The interfaces <command>hostapd</command> will use.
7167 '';
7268 };
7369
@@ -89,8 +85,7 @@ in
8985 };
9086
9187 hwMode = mkOption {
92− default = "b";
93− example = "g";
88+ default = "g";
9489 type = types.string;
9590 description = ''
9691 Operation mode.
@@ -98,17 +93,16 @@ in
9893 '';
9994 };
10095
101− channel = mkOption {
96+ channel = mkOption {
10297 default = 7;
10398 example = 11;
10499 type = types.int;
105− description =
106− ''
100+ description = ''
107101 Channel number (IEEE 802.11)
108102 Please note that some drivers do not use this value from
109103 <command>hostapd</command> and the channel will need to be configured
110104 separately with <command>iwconfig</command>.
111− '';
105+ '';
112106 };
113107
114108 group = mkOption {
@@ -131,16 +125,15 @@ in
131125 default = "my_sekret";
132126 example = "any_64_char_string";
133127 type = types.string;
134− description =
135− ''
128+ description = ''
136129 WPA-PSK (pre-shared-key) passphrase. Clients will need this
137130 passphrase to associate with this access point.
138131 Warning: This passphrase will get put into a world-readable file in
139132 the Nix store!
140− '';
133+ '';
141134 };
142135
143− extraCfg = mkOption {
136+ extraConfig = mkOption {
144137 default = "";
145138 example = ''
146139 auth_algo=0
@@ -158,17 +151,25 @@ in
158151
159152 config = mkIf cfg.enable {
160153
154+ assertions = [
155+ { assertion = (cfg.hwMode == "a" || cfg.hwMode == "b" || cfg.hwMode == "g");
156+ message = "hwMode must be a/b/g";
157+ }
158+ { assertion = (cfg.channel >= 1 && cfg.channel <= 13);
159+ message = "channel must be between 1 and 13";
160+ }];
161+
161162 environment.systemPackages = [ pkgs.hostapd ];
162163
163164 systemd.services.hostapd =
164165 { description = "hostapd wireless AP";
165166
166− path = [ pkgs.hostapd ];
167+ path = [ pkgs.hostapd ];
167168 wantedBy = [ "network.target" ];
168169
169170 after = [ "${cfg.interface}-cfg.service" "nat.service" "bind.service" "dhcpd.service"];
170171
171− serviceConfig =
172+ serviceConfig =
172173 { ExecStart = "${pkgs.hostapd}/bin/hostapd ${configFile}";
173174 Restart = "always";
174175 };