Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "nixos/wireless: make wireless.interfaces mandatory" #126075

Merged
merged 2 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions nixos/doc/manual/release-notes/rl-2105.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,6 @@
<para>GNOME desktop environment was upgraded to 40, see the release notes for <link xlink:href="https://help.gnome.org/misc/release-notes/40.0/">40.0</link> and <link xlink:href="https://help.gnome.org/misc/release-notes/3.38/">3.38</link>. The <code>gnome3</code> attribute set has been renamed to <code>gnome</code> and so have been the NixOS options.</para>
</listitem>

<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
Expand Down
40 changes: 30 additions & 10 deletions nixos/modules/services/networking/wpa_supplicant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ 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.
lukegb marked this conversation as resolved.
Show resolved Hide resolved
<warning><para>
The automatic discovery of interfaces does not work reliably on boot:
it may fail and leave the system without network. When possible, specify
a known interface name.
</para></warning>
'';
};

Expand Down Expand Up @@ -219,18 +225,19 @@ 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'';
});

warnings =
optional (cfg.interfaces == [] && config.systemd.services.wpa_supplicant.wantedBy != [])
''
No network interfaces for wpa_supplicant have been configured: the service
may randomly fail to start at boot. You should specify at least one using the option
networking.wireless.interfaces.
'';

environment.systemPackages = [ package ];

services.dbus.packages = [ package ];
Expand Down Expand Up @@ -261,7 +268,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
'';
};
Expand Down