git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #12894 from nathan7/raw-psk

wpa_supplicant module: add an option for accepting raw PSKs

commit5bfcce9ed919164f5e46fccc71aa79082e7ae970 authorRobin Gloster <mail@glob.in> dateTue 9 Feb 2016, 17:23 (11 years ago) parent4d760ed9e986c1
1 file changed+25−3
nixos/modules/services/networking/wpa_supplicant.nix+25−3
nixos/modules/services/networking/wpa_supplicant.nix+25−3
@@ -8,11 +8,15 @@ let
88 ${optionalString cfg.userControlled.enable ''
99 ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=${cfg.userControlled.group}
1010 update_config=1''}
11− ${concatStringsSep "\n" (mapAttrsToList (ssid: networkConfig: ''
11+ ${concatStringsSep "\n" (mapAttrsToList (ssid: networkConfig: let
12+ psk = if networkConfig.psk != null
13+ then ''"${networkConfig.psk}"''
14+ else networkConfig.pskRaw;
15+ in ''
1216 network={
1317 ssid="${ssid}"
14− ${optionalString (networkConfig.psk != null) ''psk="${networkConfig.psk}"''}
15− ${optionalString (networkConfig.psk == null) ''key_mgmt=NONE''}
18+ ${optionalString (psk != null) ''psk=${psk}''}
19+ ${optionalString (psk == null) ''key_mgmt=NONE''}
1620 }
1721 '') cfg.networks)}
1822 '' else "/etc/wpa_supplicant.conf";
@@ -49,6 +53,19 @@ in {
4953
5054 Be aware that these will be written to the nix store
5155 in plaintext!
56+
57+ Mutually exclusive with <varname>pskRaw</varname>.
58+ '';
59+ };
60+
61+ pskRaw = mkOption {
62+ type = types.nullOr types.str;
63+ default = null;
64+ description = ''
65+ The network's pre-shared key in hex defaulting
66+ to being a network without any authentication.
67+
68+ Mutually exclusive with <varname>psk</varname>.
5269 '';
5370 };
5471 };
@@ -95,6 +112,11 @@ in {
95112
96113 config = mkMerge [
97114 (mkIf cfg.enable {
115+ assertions = flip mapAttrsToList cfg.networks (name: cfg: {
116+ assertion = cfg.psk == null || cfg.pskRaw == null;
117+ message = ''networking.wireless."${name}".psk and networking.wireless."${name}".pskRaw are mutually exclusive'';
118+ });
119+
98120 environment.systemPackages = [ pkgs.wpa_supplicant ];
99121
100122 services.dbus.packages = [ pkgs.wpa_supplicant ];