summary refs log tree commit diff
path: root/modules/services/networking/wpa_supplicant.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-03-04 17:21:14 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-03-04 17:21:14 +0000
commit356ff794001f422412a1c464940273abcf85a406 (patch)
tree906f7527ec5513f6775f842ddd3fe472de3e1afb /modules/services/networking/wpa_supplicant.nix
parent8935db253cfd7a3719a0addf89420042180f4a57 (diff)
downloadnixpkgs-356ff794001f422412a1c464940273abcf85a406.tar
nixpkgs-356ff794001f422412a1c464940273abcf85a406.tar.gz
nixpkgs-356ff794001f422412a1c464940273abcf85a406.tar.bz2
nixpkgs-356ff794001f422412a1c464940273abcf85a406.tar.lz
nixpkgs-356ff794001f422412a1c464940273abcf85a406.tar.xz
nixpkgs-356ff794001f422412a1c464940273abcf85a406.tar.zst
nixpkgs-356ff794001f422412a1c464940273abcf85a406.zip
* wpa_supplicant: automatically figure out the wireless interface(s)
  on which to run wpa_supplicant, unless they're set explicitly.

svn path=/nixos/trunk/; revision=32777
Diffstat (limited to 'modules/services/networking/wpa_supplicant.nix')
-rw-r--r--modules/services/networking/wpa_supplicant.nix36
1 files changed, 29 insertions, 7 deletions
diff --git a/modules/services/networking/wpa_supplicant.nix b/modules/services/networking/wpa_supplicant.nix
index bf4cd6ae29a..795a766b836 100644
--- a/modules/services/networking/wpa_supplicant.nix
+++ b/modules/services/networking/wpa_supplicant.nix
@@ -6,6 +6,10 @@ let
 
   configFile = "/etc/wpa_supplicant.conf";
 
+  ifaces =
+    config.networking.wireless.interfaces ++
+    optional (config.networking.WLANInterface != "") config.networking.WLANInterface;
+
 in
 
 {
@@ -14,7 +18,7 @@ in
 
   options = {
   
-    networking.enableWLAN = mkOption {
+    networking.wireless.enable = mkOption {
       default = false;
       description = ''
         Whether to start <command>wpa_supplicant</command> to scan for
@@ -29,9 +33,16 @@ in
     };
 
     networking.WLANInterface = mkOption {
-      default = "wlan0";
+      default = "";
+      description = "Obsolete. Use <option>networking.wireless.interfaces</option> instead.";
+    };
+
+    networking.wireless.interfaces = mkOption {
+      default = [];
+      example = [ "wlan0" "wlan1" ];
       description = ''
-        The interface wpa_supplicant will use, if enableWLAN is set.
+        The interfaces <command>wpa_supplicant</command> will use.  If empty, it will
+        automatically use all wireless interfaces.
       '';
     };
 
@@ -40,7 +51,7 @@ in
 
   ###### implementation
   
-  config = mkIf config.networking.enableWLAN {
+  config = mkIf config.networking.wireless.enable {
 
     environment.systemPackages =  [ pkgs.wpa_supplicant ];
 
@@ -58,9 +69,20 @@ in
             chmod 600 ${configFile}
           '';
 
-        exec =
-          "wpa_supplicant -s -u -c ${configFile} "
-          + (optionalString (config.networking.WLANInterface != null) "-i ${config.networking.WLANInterface}");
+        script =
+          ''
+            ${if ifaces == [] then ''
+              for i in $(cd /sys/class/net && echo *); do
+                if [ -e /sys/class/net/$i/wireless ]; then
+                  ifaces="$ifaces''${ifaces:+ -N} -i$i"
+                fi
+              done
+            '' else ''
+              ifaces="${concatStringsSep " -N " (map (i: "-i${i}") ifaces)}"
+            ''}
+            echo "|$ifaces|"
+            exec wpa_supplicant -s -u -c ${configFile} $ifaces
+          '';
       };
   
     powerManagement.resumeCommands =