diff options
author | Michele Guerini Rocco <rnhmjoj@users.noreply.github.com> | 2020-12-15 08:37:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-15 08:37:33 +0100 |
commit | 12f367b51cafa511161b1af76f9ccc47c2dde6cb (patch) | |
tree | 629e398f178528533f82868be6dc91256491caa2 | |
parent | 46e2a315adebe1b67dfcf83769e9597efc2ccf4d (diff) | |
parent | 8f177612b14063b644288a5a1058bf47f44b43a5 (diff) |
Merge pull request #104722 from rnhmjoj/wpa-fix
nixos/wireless: fix failure with no interfaces
-rw-r--r-- | nixos/modules/services/networking/wpa_supplicant.nix | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix index 395139879036..3cfcb535ef5b 100644 --- a/nixos/modules/services/networking/wpa_supplicant.nix +++ b/nixos/modules/services/networking/wpa_supplicant.nix @@ -233,9 +233,10 @@ in { path = [ pkgs.wpa_supplicant ]; script = '' - if [ -f /etc/wpa_supplicant.conf -a "/etc/wpa_supplicant.conf" != "${configFile}" ] - then echo >&2 "<3>/etc/wpa_supplicant.conf present but ignored. Generated ${configFile} is used instead." + if [ -f /etc/wpa_supplicant.conf -a "/etc/wpa_supplicant.conf" != "${configFile}" ]; then + echo >&2 "<3>/etc/wpa_supplicant.conf present but ignored. Generated ${configFile} is used instead." fi + iface_args="-s -u -D${cfg.driver} -c ${configFile}" ${if ifaces == [] then '' for i in $(cd /sys/class/net && echo *); do @@ -248,6 +249,10 @@ in { fi fi done + if [ -z "$args" ]; then + echo >&2 "<3>No wireless interfaces detected (yet)." + exit 1 + fi '' else '' args="${concatMapStringsSep " -N " (i: "-i${i} $iface_args") ifaces}" ''} @@ -261,7 +266,7 @@ in { # Restart wpa_supplicant when a wlan device appears or disappears. services.udev.extraRules = '' - ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="/run/current-system/systemd/bin/systemctl try-restart wpa_supplicant.service" + ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="/run/current-system/systemd/bin/systemctl restart wpa_supplicant.service" ''; }; |