diff options
author | Nathan Zadoks <nathan@nathan7.eu> | 2016-02-09 16:53:11 +0100 |
---|---|---|
committer | Nathan Zadoks <nathan@nathan7.eu> | 2016-02-09 17:20:35 +0100 |
commit | 9e986c161b8127d16063ff5c0da7aad4639422c8 (patch) | |
tree | db4f07f73f4f8f57978f6efb82bae52e87fe5d03 /nixos/modules | |
parent | 75739fd05b5d646d007e4df3c94bdefb5c12845d (diff) | |
download | nixlib-9e986c161b8127d16063ff5c0da7aad4639422c8.tar nixlib-9e986c161b8127d16063ff5c0da7aad4639422c8.tar.gz nixlib-9e986c161b8127d16063ff5c0da7aad4639422c8.tar.bz2 nixlib-9e986c161b8127d16063ff5c0da7aad4639422c8.tar.lz nixlib-9e986c161b8127d16063ff5c0da7aad4639422c8.tar.xz nixlib-9e986c161b8127d16063ff5c0da7aad4639422c8.tar.zst nixlib-9e986c161b8127d16063ff5c0da7aad4639422c8.zip |
wpa_supplicant module: add an option for accepting raw PSKs
fix #12892
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/networking/wpa_supplicant.nix | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix index 1b655af6c82d..1558c5832892 100644 --- a/nixos/modules/services/networking/wpa_supplicant.nix +++ b/nixos/modules/services/networking/wpa_supplicant.nix @@ -8,11 +8,15 @@ let ${optionalString cfg.userControlled.enable '' ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=${cfg.userControlled.group} 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={ ssid="${ssid}" - ${optionalString (networkConfig.psk != null) ''psk="${networkConfig.psk}"''} - ${optionalString (networkConfig.psk == null) ''key_mgmt=NONE''} + ${optionalString (psk != null) ''psk=${psk}''} + ${optionalString (psk == null) ''key_mgmt=NONE''} } '') cfg.networks)} '' else "/etc/wpa_supplicant.conf"; @@ -49,6 +53,19 @@ in { Be aware that these will be written to the nix store 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 [ (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 ]; services.dbus.packages = [ pkgs.wpa_supplicant ]; |