summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2021-06-07 15:55:58 +0200
committerJonathan Ringer <jonringer@users.noreply.github.com>2021-06-08 08:52:41 -0700
commitdf9df54d637da87dc577026cd973b80704ee27c1 (patch)
treea2a22483494c983a990c03bc6321c030427dd931
parentMerge pull request #126031 from NixOS/backport-125902-to-release-21.05 (diff)
downloadnixpkgs-df9df54d637da87dc577026cd973b80704ee27c1.tar.gz
Revert "nixos/wireless: make wireless.interfaces mandatory"
This reverts commit 030a521adc9510207dd9f06b8d8b552ff7d999f9. (cherry picked from commit eba5f5c1e5a61ef65a970c699b9f93aff87448bf)
-rw-r--r--nixos/doc/manual/release-notes/rl-2105.xml9
-rw-r--r--nixos/modules/services/networking/wpa_supplicant.nix27
2 files changed, 17 insertions, 19 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2105.xml b/nixos/doc/manual/release-notes/rl-2105.xml
index c6b1ce212def..124ede127268 100644
--- a/nixos/doc/manual/release-notes/rl-2105.xml
+++ b/nixos/doc/manual/release-notes/rl-2105.xml
@@ -183,15 +183,6 @@
<listitem>
<para>
- Enabling wireless networking now requires specifying at least one network
- interface using <xref linkend="opt-networking.wireless.interfaces"/>.
- This is to avoid a race condition with the card initialisation (see
- <link xlink:href="https://github.com/NixOS/nixpkgs/issues/101963">issue
- #101963</link> for more information).
- </para>
- </listitem>
- <listitem>
- <para>
If you are using <option>services.udev.extraRules</option> to assign
custom names to network interfaces, this may stop working due to a change
in the initialisation of dhcpcd and systemd networkd. To avoid this, either
diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix
index d9308b37064a..8a0685c3d96b 100644
--- a/nixos/modules/services/networking/wpa_supplicant.nix
+++ b/nixos/modules/services/networking/wpa_supplicant.nix
@@ -40,7 +40,8 @@ in {
default = [];
example = [ "wlan0" "wlan1" ];
description = ''
- The interfaces <command>wpa_supplicant</command> will use.
+ The interfaces <command>wpa_supplicant</command> will use. If empty, it will
+ automatically use all wireless interfaces.
'';
};
@@ -219,14 +220,7 @@ in {
};
config = mkIf cfg.enable {
- assertions = [
- { assertion = cfg.interfaces != [];
- message = ''
- No network interfaces for wpa_supplicant have been configured.
- Please, specify at least one using networking.wireless.interfaces.
- '';
- }
- ] ++ flip mapAttrsToList cfg.networks (name: cfg: {
+ assertions = flip mapAttrsToList cfg.networks (name: cfg: {
assertion = with cfg; count (x: x != null) [ psk pskRaw auth ] <= 1;
message = ''options networking.wireless."${name}".{psk,pskRaw,auth} are mutually exclusive'';
});
@@ -261,7 +255,20 @@ in {
then echo >&2 "<3>/etc/wpa_supplicant.conf present but ignored. Generated ${configFile} is used instead."
fi
iface_args="-s -u -D${cfg.driver} ${configStr}"
- args="${concatMapStringsSep " -N " (i: "-i${i} $iface_args") ifaces}"
+ ${if ifaces == [] then ''
+ for i in $(cd /sys/class/net && echo *); do
+ DEVTYPE=
+ UEVENT_PATH=/sys/class/net/$i/uevent
+ if [ -e "$UEVENT_PATH" ]; then
+ source "$UEVENT_PATH"
+ if [ "$DEVTYPE" = "wlan" -o -e /sys/class/net/$i/wireless ]; then
+ args+="''${args:+ -N} -i$i $iface_args"
+ fi
+ fi
+ done
+ '' else ''
+ args="${concatMapStringsSep " -N " (i: "-i${i} $iface_args") ifaces}"
+ ''}
exec wpa_supplicant $args
'';
};