hostapd: rename extraCfg -> extraConfig, added asserts

This commit is contained in:
Jakob Gillich 2015-12-26 11:35:56 +01:00
parent 5a2f0541a1
commit ae4a7f9351
2 changed files with 26 additions and 23 deletions

View File

@ -75,6 +75,8 @@ with lib;
# DNSCrypt-proxy
(mkRenamedOptionModule [ "services" "dnscrypt-proxy" "port" ] [ "services" "dnscrypt-proxy" "localPort" ])
(mkRenamedOptionModule [ "services" "hostapd" "extraCfg" ] [ "services" "hostapd" "extraConfig" ])
# Options that are obsolete and have no replacement.
(mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ])
(mkRemovedOptionModule [ "programs" "bash" "enable" ])

View File

@ -4,10 +4,7 @@
#
# asserts
# ensure that the nl80211 module is loaded/compiled in the kernel
# hwMode must be a/b/g
# channel must be between 1 and 13 (maybe)
# wpa_supplicant and hostapd on the same wireless interface doesn't make any sense
# perhaps an assertion that there is a dhcp server and a dns server on the IP address serviced by the hostapd?
with lib;
@ -15,8 +12,7 @@ let
cfg = config.services.hostapd;
configFile = pkgs.writeText "hostapd.conf"
''
configFile = pkgs.writeText "hostapd.conf" ''
interface=${cfg.interface}
driver=${cfg.driver}
ssid=${cfg.ssid}
@ -37,7 +33,7 @@ let
wpa_passphrase=${cfg.wpaPassphrase}
'' else ""}
${cfg.extraCfg}
${cfg.extraConfig}
'' ;
in
@ -65,7 +61,7 @@ in
interface = mkOption {
default = "";
example = "wlan0";
example = "wlp2s0";
description = ''
The interfaces <command>hostapd</command> will use.
'';
@ -89,8 +85,7 @@ in
};
hwMode = mkOption {
default = "b";
example = "g";
default = "g";
type = types.string;
description = ''
Operation mode.
@ -102,8 +97,7 @@ in
default = 7;
example = 11;
type = types.int;
description =
''
description = ''
Channel number (IEEE 802.11)
Please note that some drivers do not use this value from
<command>hostapd</command> and the channel will need to be configured
@ -131,8 +125,7 @@ in
default = "my_sekret";
example = "any_64_char_string";
type = types.string;
description =
''
description = ''
WPA-PSK (pre-shared-key) passphrase. Clients will need this
passphrase to associate with this access point.
Warning: This passphrase will get put into a world-readable file in
@ -140,7 +133,7 @@ in
'';
};
extraCfg = mkOption {
extraConfig = mkOption {
default = "";
example = ''
auth_algo=0
@ -158,6 +151,14 @@ in
config = mkIf cfg.enable {
assertions = [
{ assertion = (cfg.hwMode == "a" || cfg.hwMode == "b" || cfg.hwMode == "g");
message = "hwMode must be a/b/g";
}
{ assertion = (cfg.channel >= 1 && cfg.channel <= 13);
message = "channel must be between 1 and 13";
}];
environment.systemPackages = [ pkgs.hostapd ];
systemd.services.hostapd =