hostapd: rename extraCfg -> extraConfig, added asserts
This commit is contained in:
parent
5a2f0541a1
commit
ae4a7f9351
@ -75,6 +75,8 @@ with lib;
|
|||||||
# DNSCrypt-proxy
|
# DNSCrypt-proxy
|
||||||
(mkRenamedOptionModule [ "services" "dnscrypt-proxy" "port" ] [ "services" "dnscrypt-proxy" "localPort" ])
|
(mkRenamedOptionModule [ "services" "dnscrypt-proxy" "port" ] [ "services" "dnscrypt-proxy" "localPort" ])
|
||||||
|
|
||||||
|
(mkRenamedOptionModule [ "services" "hostapd" "extraCfg" ] [ "services" "hostapd" "extraConfig" ])
|
||||||
|
|
||||||
# Options that are obsolete and have no replacement.
|
# Options that are obsolete and have no replacement.
|
||||||
(mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ])
|
(mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ])
|
||||||
(mkRemovedOptionModule [ "programs" "bash" "enable" ])
|
(mkRemovedOptionModule [ "programs" "bash" "enable" ])
|
||||||
|
@ -4,10 +4,7 @@
|
|||||||
#
|
#
|
||||||
# asserts
|
# asserts
|
||||||
# ensure that the nl80211 module is loaded/compiled in the kernel
|
# 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
|
# 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;
|
with lib;
|
||||||
|
|
||||||
@ -15,8 +12,7 @@ let
|
|||||||
|
|
||||||
cfg = config.services.hostapd;
|
cfg = config.services.hostapd;
|
||||||
|
|
||||||
configFile = pkgs.writeText "hostapd.conf"
|
configFile = pkgs.writeText "hostapd.conf" ''
|
||||||
''
|
|
||||||
interface=${cfg.interface}
|
interface=${cfg.interface}
|
||||||
driver=${cfg.driver}
|
driver=${cfg.driver}
|
||||||
ssid=${cfg.ssid}
|
ssid=${cfg.ssid}
|
||||||
@ -37,8 +33,8 @@ let
|
|||||||
wpa_passphrase=${cfg.wpaPassphrase}
|
wpa_passphrase=${cfg.wpaPassphrase}
|
||||||
'' else ""}
|
'' else ""}
|
||||||
|
|
||||||
${cfg.extraCfg}
|
${cfg.extraConfig}
|
||||||
'' ;
|
'' ;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -65,7 +61,7 @@ in
|
|||||||
|
|
||||||
interface = mkOption {
|
interface = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "wlan0";
|
example = "wlp2s0";
|
||||||
description = ''
|
description = ''
|
||||||
The interfaces <command>hostapd</command> will use.
|
The interfaces <command>hostapd</command> will use.
|
||||||
'';
|
'';
|
||||||
@ -89,8 +85,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
hwMode = mkOption {
|
hwMode = mkOption {
|
||||||
default = "b";
|
default = "g";
|
||||||
example = "g";
|
|
||||||
type = types.string;
|
type = types.string;
|
||||||
description = ''
|
description = ''
|
||||||
Operation mode.
|
Operation mode.
|
||||||
@ -102,13 +97,12 @@ in
|
|||||||
default = 7;
|
default = 7;
|
||||||
example = 11;
|
example = 11;
|
||||||
type = types.int;
|
type = types.int;
|
||||||
description =
|
description = ''
|
||||||
''
|
|
||||||
Channel number (IEEE 802.11)
|
Channel number (IEEE 802.11)
|
||||||
Please note that some drivers do not use this value from
|
Please note that some drivers do not use this value from
|
||||||
<command>hostapd</command> and the channel will need to be configured
|
<command>hostapd</command> and the channel will need to be configured
|
||||||
separately with <command>iwconfig</command>.
|
separately with <command>iwconfig</command>.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
group = mkOption {
|
group = mkOption {
|
||||||
@ -131,16 +125,15 @@ in
|
|||||||
default = "my_sekret";
|
default = "my_sekret";
|
||||||
example = "any_64_char_string";
|
example = "any_64_char_string";
|
||||||
type = types.string;
|
type = types.string;
|
||||||
description =
|
description = ''
|
||||||
''
|
|
||||||
WPA-PSK (pre-shared-key) passphrase. Clients will need this
|
WPA-PSK (pre-shared-key) passphrase. Clients will need this
|
||||||
passphrase to associate with this access point.
|
passphrase to associate with this access point.
|
||||||
Warning: This passphrase will get put into a world-readable file in
|
Warning: This passphrase will get put into a world-readable file in
|
||||||
the Nix store!
|
the Nix store!
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extraCfg = mkOption {
|
extraConfig = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = ''
|
example = ''
|
||||||
auth_algo=0
|
auth_algo=0
|
||||||
@ -158,6 +151,14 @@ in
|
|||||||
|
|
||||||
config = mkIf cfg.enable {
|
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 ];
|
environment.systemPackages = [ pkgs.hostapd ];
|
||||||
|
|
||||||
systemd.services.hostapd =
|
systemd.services.hostapd =
|
||||||
|
Loading…
Reference in New Issue
Block a user