Author: eelco
Date: Sun Mar 4 17:21:14 2012
New Revision: 32777
URL: https://nixos.org/websvn/nix/?rev=32777&sc=1
Log:
* wpa_supplicant: automatically figure out the wireless interface(s)
on which to run wpa_supplicant, unless they're set explicitly.
Modified:
nixos/trunk/modules/rename.nix
nixos/trunk/modules/services/networking/wpa_supplicant.nix
Modified: nixos/trunk/modules/rename.nix
==============================================================================
--- nixos/trunk/modules/rename.nix Sun Mar 4 16:34:01 2012 (r32776)
+++ nixos/trunk/modules/rename.nix Sun Mar 4 17:21:14 2012 (r32777)
@@ -68,6 +68,7 @@
++ rename obsolete "environment.extraPackages" "environment.systemPackages"
++ rename obsolete "security.extraSetuidPrograms" "security.setuidPrograms"
+++ rename obsolete "networking.enableWLAN" "networking.wireless.enable"
# Old Grub-related options.
++ rename obsolete "boot.copyKernels" "boot.loader.grub.copyKernels"
Modified: nixos/trunk/modules/services/networking/wpa_supplicant.nix
==============================================================================
--- nixos/trunk/modules/services/networking/wpa_supplicant.nix Sun Mar 4
16:34:01 2012 (r32776)
+++ nixos/trunk/modules/services/networking/wpa_supplicant.nix Sun Mar 4
17:21:14 2012 (r32777)
@@ -6,6 +6,10 @@
configFile = "/etc/wpa_supplicant.conf";
+ ifaces =
+ config.networking.wireless.interfaces ++
+ optional (config.networking.WLANInterface != "")
config.networking.WLANInterface;
+
in
{
@@ -14,7 +18,7 @@
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 @@
};
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 @@
###### implementation
- config = mkIf config.networking.enableWLAN {
+ config = mkIf config.networking.wireless.enable {
environment.systemPackages = [ pkgs.wpa_supplicant ];
@@ -58,9 +69,20 @@
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 =
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits