NixOS: can't enable connman
+wpa_supplicant
due to missing /etc/wpa_supplicant.conf
#212347
Labels
0.kind: bug
Something is broken
Describe the bug
When enabling
connman
withwpa_supplicant
backend,nixos-rebuild switch
fails to switch over to the new configuration. Specifically it tries to launch thewpa_supplicant
service but crashes with the error message (full screenshot below):Steps To Reproduce
Steps to reproduce the behavior:
services.connman={enable=true; wifi.backend="wpa_supplicant";}
.nixos-rebuild switch
(assumingconnman
/wpa_supplicant
aren't already active and running, which should be true on a fresh install, this should cause NixOS to try to start thewpa_supplicant
service).Expected behavior
No crash;
wpa_supplicant
should launch without error, because, as discussed in previous instances of similar issues,connman
interacts withwpa_supplicant
directly and so shouldn't/doesn't need/etc/wpa_supplicant.conf
to exist. Ifwpa_supplicant
really depends on the existence of a configuration file, then theconnman
module should create a dummy blank configuration file instead of causing a crash.Additional context
Here are some relevant past issues, though this one seems to be different than all of the other ones:
nixos-rebuild boot
instead ofnixos-rebuild switch
reproduces the same symptoms as that issue; the difference is thatboot
doesn't immediately try to switch over to the new configuration and so doesn't trigger the "failed to launchwpa_supplicant.service
" error. I suspect that what's going on there is simply that systemd tries to start thewpa_supplicant
service at boot, silently fails, and so upon startupconnman
fails to interact withwpa_supplicant
and therefore reports "Not supported" when trying to scan.wpa_supplicant
erroneously failing to start due to a missing/etc/wpa_supplicant.conf
. However, that issue is almost six years old and exhibits a different error message than encountered here; the NixOS module source has evolved significantly since then, and so while the/etc/wpa_supplicant.conf
aspect of the issue is the same, the underlying cause might not be. In fact, nixos/wireless: use udev to wait for interfaces #127595 claims to have resolved that issue over a year ago (on Aug 11, 2021), but the code introducing this error (as far as I can tell; details provided below) was added a week after that fix (52b9dd7 on Aug 17, 2021).Detailed below is my attempt to track down the cause of the issue. The failed
wpa_supplicant
systemd service points to awpa_supplicant-start
script with the following contents:In particular the crash is caused by the
awk
invocation (under thesubstitute environment variables
comment): it tries to read from/etc/wpa_supplicant.conf
but fails because that file doesn't exist. Grepping for these lines in the NixOS module source code (currently thenixos-22.11
branch as of writing) takes us to this code innixos/modules/services/networking/wpa_supplicant.conf
:nixpkgs/nixos/modules/services/networking/wpa_supplicant.nix
Lines 124 to 128 in cdead16
Viewing
git blame
of this code points to commit 52b9dd7 by @rnhmjoj.I don't fully understand what the aforementioned code is meant to do; nor do I know exactly how
connman
/wpa_supplicant
operates, so I'm not sure what solution to offer here, though I'm guessing the fix is relatively simple--omit this code when the configuration file isn't needed (e.g., whenwpa_supplicant
is enabled throughconnman
). Alternatively (as was previously suggested in #23196) have theconnman
module auto-create a blank dummy/etc/wpa_supplicant.conf
(see the workaround suggested by #23196 (comment)). I'm sure more knowledgeable people than me have well-formed thoughts on this.Workaround
Until the issue is fixed officially, the issue can be locally sidestepped either by manually creating a dummy conf file (
sudo touch /etc/wpa_supplicant.conf
), or, if you'd really rather do things declaratively, with the following configuration snippet suggested by #23196 (comment):Notify maintainers
@rnhmjoj
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result."x86_64-linux"
Linux 5.15.86, NixOS, 22.11 (Raccoon), 22.11.20230112.6a3f999
yes
yes
nix-env (Nix) 2.11.1
""
""
/nix/store/mi6xqy0h44p5ryh4sh8p8v3rwqgar0hb-source
The text was updated successfully, but these errors were encountered: