Merge pull request #12894 from nathan7/raw-psk

wpa_supplicant module: add an option for accepting raw PSKs
This commit is contained in:
Robin Gloster 2016-02-09 17:23:24 +01:00
commit 5bfcce9ed9

View File

@ -8,11 +8,15 @@ let
${optionalString cfg.userControlled.enable '' ${optionalString cfg.userControlled.enable ''
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=${cfg.userControlled.group} ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=${cfg.userControlled.group}
update_config=1''} update_config=1''}
${concatStringsSep "\n" (mapAttrsToList (ssid: networkConfig: '' ${concatStringsSep "\n" (mapAttrsToList (ssid: networkConfig: let
psk = if networkConfig.psk != null
then ''"${networkConfig.psk}"''
else networkConfig.pskRaw;
in ''
network={ network={
ssid="${ssid}" ssid="${ssid}"
${optionalString (networkConfig.psk != null) ''psk="${networkConfig.psk}"''} ${optionalString (psk != null) ''psk=${psk}''}
${optionalString (networkConfig.psk == null) ''key_mgmt=NONE''} ${optionalString (psk == null) ''key_mgmt=NONE''}
} }
'') cfg.networks)} '') cfg.networks)}
'' else "/etc/wpa_supplicant.conf"; '' else "/etc/wpa_supplicant.conf";
@ -49,6 +53,19 @@ in {
Be aware that these will be written to the nix store Be aware that these will be written to the nix store
in plaintext! in plaintext!
Mutually exclusive with <varname>pskRaw</varname>.
'';
};
pskRaw = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The network's pre-shared key in hex defaulting
to being a network without any authentication.
Mutually exclusive with <varname>psk</varname>.
''; '';
}; };
}; };
@ -95,6 +112,11 @@ in {
config = mkMerge [ config = mkMerge [
(mkIf cfg.enable { (mkIf cfg.enable {
assertions = flip mapAttrsToList cfg.networks (name: cfg: {
assertion = cfg.psk == null || cfg.pskRaw == null;
message = ''networking.wireless."${name}".psk and networking.wireless."${name}".pskRaw are mutually exclusive'';
});
environment.systemPackages = [ pkgs.wpa_supplicant ]; environment.systemPackages = [ pkgs.wpa_supplicant ];
services.dbus.packages = [ pkgs.wpa_supplicant ]; services.dbus.packages = [ pkgs.wpa_supplicant ];