summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-05-06 11:01:35 +0200
committerGitHub <noreply@github.com>2021-05-06 11:01:35 +0200
commita50b9e6c230c06ec83eb20f0b317a71a5e8fcb11 (patch)
tree0d9b7460289a8e27ab694c93012ecd335d923146 /nixos/modules
parent77b82f3535a627a11972035e2c22154a8068d14b (diff)
parent84670bf6812670d20c9cecf996c927cf85b51445 (diff)
downloadnixpkgs-a50b9e6c230c06ec83eb20f0b317a71a5e8fcb11.tar
nixpkgs-a50b9e6c230c06ec83eb20f0b317a71a5e8fcb11.tar.gz
nixpkgs-a50b9e6c230c06ec83eb20f0b317a71a5e8fcb11.tar.bz2
nixpkgs-a50b9e6c230c06ec83eb20f0b317a71a5e8fcb11.tar.lz
nixpkgs-a50b9e6c230c06ec83eb20f0b317a71a5e8fcb11.tar.xz
nixpkgs-a50b9e6c230c06ec83eb20f0b317a71a5e8fcb11.tar.zst
nixpkgs-a50b9e6c230c06ec83eb20f0b317a71a5e8fcb11.zip
Merge pull request #113716 from Ma27/wpa_multiple
wpa_supplicant: allow both imperative and declarative networks
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/networking/wpa_supplicant.nix28
1 files changed, 23 insertions, 5 deletions
diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix
index 61482596763..8a0685c3d96 100644
--- a/nixos/modules/services/networking/wpa_supplicant.nix
+++ b/nixos/modules/services/networking/wpa_supplicant.nix
@@ -3,6 +3,10 @@
 with lib;
 
 let
+  package = if cfg.allowAuxiliaryImperativeNetworks
+    then pkgs.wpa_supplicant_ro_ssids
+    else pkgs.wpa_supplicant;
+
   cfg = config.networking.wireless;
   configFile = if cfg.networks != {} || cfg.extraConfig != "" || cfg.userControlled.enable then pkgs.writeText "wpa_supplicant.conf" ''
     ${optionalString cfg.userControlled.enable ''
@@ -47,6 +51,16 @@ in {
         description = "Force a specific wpa_supplicant driver.";
       };
 
+      allowAuxiliaryImperativeNetworks = mkEnableOption "support for imperative & declarative networks" // {
+        description = ''
+          Whether to allow configuring networks "imperatively" (e.g. via
+          <package>wpa_supplicant_gui</package>) and declaratively via
+          <xref linkend="opt-networking.wireless.networks" />.
+
+          Please note that this adds a custom patch to <package>wpa_supplicant</package>.
+        '';
+      };
+
       networks = mkOption {
         type = types.attrsOf (types.submodule {
           options = {
@@ -211,9 +225,9 @@ in {
       message = ''options networking.wireless."${name}".{psk,pskRaw,auth} are mutually exclusive'';
     });
 
-    environment.systemPackages =  [ pkgs.wpa_supplicant ];
+    environment.systemPackages = [ package ];
 
-    services.dbus.packages = [ pkgs.wpa_supplicant ];
+    services.dbus.packages = [ package ];
     services.udev.packages = [ pkgs.crda ];
 
     # FIXME: start a separate wpa_supplicant instance per interface.
@@ -230,13 +244,17 @@ in {
       wantedBy = [ "multi-user.target" ];
       stopIfChanged = false;
 
-      path = [ pkgs.wpa_supplicant ];
+      path = [ package ];
 
-      script = ''
+      script = let
+        configStr = if cfg.allowAuxiliaryImperativeNetworks
+          then "-c /etc/wpa_supplicant.conf -I ${configFile}"
+          else "-c ${configFile}";
+      in ''
         if [ -f /etc/wpa_supplicant.conf -a "/etc/wpa_supplicant.conf" != "${configFile}" ]
         then echo >&2 "<3>/etc/wpa_supplicant.conf present but ignored. Generated ${configFile} is used instead."
         fi
-        iface_args="-s -u -D${cfg.driver} -c ${configFile}"
+        iface_args="-s -u -D${cfg.driver} ${configStr}"
         ${if ifaces == [] then ''
           for i in $(cd /sys/class/net && echo *); do
             DEVTYPE=