git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #126075 from rnhmjoj/fixup

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

commit631250e8186b39e79e3d9e63a926aaac2c34dc91 authorLuke Granger-Brown <git@lukegb.com> dateTue 8 Jun 2021, 14:04 (5 years ago) parent1f22c13be01320
2 files changed+30−19
nixos/doc/manual/release-notes/rl-2105.xml−9 nixos/modules/services/networking/wpa_supplicant.nix+30−10
nixos/doc/manual/release-notes/rl-2105.xml−9
@@ -181,15 +181,6 @@
181181 <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>
182182 </listitem>
183183
184− <listitem>
185− <para>
186− Enabling wireless networking now requires specifying at least one network
187− interface using <xref linkend="opt-networking.wireless.interfaces"/>.
188− This is to avoid a race condition with the card initialisation (see
189− <link xlink:href="https://github.com/NixOS/nixpkgs/issues/101963">issue
190− #101963</link> for more information).
191− </para>
192− </listitem>
193184 <listitem>
194185 <para>
195186 If you are using <option>services.udev.extraRules</option> to assign
nixos/modules/services/networking/wpa_supplicant.nix+30−10
@@ -40,7 +40,13 @@ in {
4040 default = [];
4141 example = [ "wlan0" "wlan1" ];
4242 description = ''
43− The interfaces <command>wpa_supplicant</command> will use.
43+ The interfaces <command>wpa_supplicant</command> will use. If empty, it will
44+ automatically use all wireless interfaces.
45+ <warning><para>
46+ The automatic discovery of interfaces does not work reliably on boot:
47+ it may fail and leave the system without network. When possible, specify
48+ a known interface name.
49+ </para></warning>
4450 '';
4551 };
4652
@@ -219,18 +225,19 @@ in {
219225 };
220226
221227 config = mkIf cfg.enable {
222− assertions = [
223− { assertion = cfg.interfaces != [];
224− message = ''
225− No network interfaces for wpa_supplicant have been configured.
226− Please, specify at least one using networking.wireless.interfaces.
227− '';
228− }
229− ] ++ flip mapAttrsToList cfg.networks (name: cfg: {
228+ assertions = flip mapAttrsToList cfg.networks (name: cfg: {
230229 assertion = with cfg; count (x: x != null) [ psk pskRaw auth ] <= 1;
231230 message = ''options networking.wireless."${name}".{psk,pskRaw,auth} are mutually exclusive'';
232231 });
233232
233+ warnings =
234+ optional (cfg.interfaces == [] && config.systemd.services.wpa_supplicant.wantedBy != [])
235+ ''
236+ No network interfaces for wpa_supplicant have been configured: the service
237+ may randomly fail to start at boot. You should specify at least one using the option
238+ networking.wireless.interfaces.
239+ '';
240+
234241 environment.systemPackages = [ package ];
235242
236243 services.dbus.packages = [ package ];
@@ -261,7 +268,20 @@ in {
261268 then echo >&2 "<3>/etc/wpa_supplicant.conf present but ignored. Generated ${configFile} is used instead."
262269 fi
263270 iface_args="-s -u -D${cfg.driver} ${configStr}"
264− args="${concatMapStringsSep " -N " (i: "-i${i} $iface_args") ifaces}"
271+ ${if ifaces == [] then ''
272+ for i in $(cd /sys/class/net && echo *); do
273+ DEVTYPE=
274+ UEVENT_PATH=/sys/class/net/$i/uevent
275+ if [ -e "$UEVENT_PATH" ]; then
276+ source "$UEVENT_PATH"
277+ if [ "$DEVTYPE" = "wlan" -o -e /sys/class/net/$i/wireless ]; then
278+ args+="''${args:+ -N} -i$i $iface_args"
279+ fi
280+ fi
281+ done
282+ '' else ''
283+ args="${concatMapStringsSep " -N " (i: "-i${i} $iface_args") ifaces}"
284+ ''}
265285 exec wpa_supplicant $args
266286 '';
267287 };