nixpkgs/nixos/modules/services/networking
rnhmjoj 99e8af51b2
nixos/wireless: use udev to wait for interfaces
I may have finally found a clean solution to the issues[1][2][3] with
the automatic discovery of wireless network interfaces.

[1]: https://github.com/NixOS/nixpkgs/issues/101963
[2]: https://github.com/NixOS/nixpkgs/issues/23196
[3]: https://github.com/NixOS/nixpkgs/pull/125917#issuecomment-856000426

Currently the start script fails right away if no interface is available
by the time it's running, possibly leaving the system without network.
This happens when running a little early in the boot. A solution is to
instead wait for at least one interface to appear before scanning the
/sys/class/net/ directory. This is done here by listening for the right
udev events (from the net/wlan subsystem) using the `udevadm monitor`
command and grep to match its output.

This methods guarantees the availability of at least one interface to
wpa_supplicant, but won't add additional interfaces once it has started.
However, if the current interface is lost, say unplugged, the service is
automatically stopped and will be restarted as soon as a one (not
necessarily the same) is detected. It would be possible make this fully
dynamic by running another service that continously listen for udev
events and manages the main wpa_supplicant daemon, but this is probably
overkill.

I tested the following cases:

  - one interface, starting at boot, w/o predictable naming scheme
  - two interfaces, starting at boot (intel wireless and a usb adapter),
    w/o predictable naming scheme
  - one interface after the system booted, w/o predictable naming scheme
  - two interfaces after the system booted, w/o predictable naming scheme
  - unplugging and plugging back the current interface
2021-08-12 00:31:06 +02:00
..
firefox
hylafax nixos/hylafax: enable ProtectKernelLogs for most services 2021-05-14 22:55:50 +02:00
icecream
ircd-hybrid
iscsi
keepalived
nghttpx
ntp
ssh nixos/ssh: Document authorizedKeysFiles properly 2021-06-15 12:23:09 +02:00
strongswan-swanctl
znc nixos/znc: fixed chown not working after hardening (#123883) 2021-05-21 19:07:53 +02:00
3proxy.nix
adguardhome.nix
amuled.nix
aria2.nix
asterisk.nix
atftpd.nix
autossh.nix
avahi-daemon.nix
babeld.nix
bee-clef.nix
bee.nix
biboumi.nix
bind.nix nixos/bind: formatted with nixpkgs-fmt 2021-05-08 23:13:58 +02:00
bird.nix
bitcoind.nix
bitlbee.nix
blockbook-frontend.nix
charybdis.nix
cjdns.nix services.cjdns: add missing, optional login & peerName attribute 2021-05-18 17:39:04 +02:00
cntlm.nix
connman.nix
consul.nix
coredns.nix
corerad.nix
coturn.nix
croc.nix treewide: remove duplicates SystemCallFilters 2021-05-13 15:44:56 +03:00
dante.nix
ddclient.nix
dhcpcd.nix
dhcpd.nix
dnscache.nix
dnscrypt-proxy2.nix
dnscrypt-wrapper.nix
dnsdist.nix
dnsmasq.nix
doh-proxy-rust.nix
ejabberd.nix
epmd.nix
ergo.nix
eternal-terminal.nix
fakeroute.nix
ferm.nix
fireqos.nix
firewall.nix
flannel.nix
freenet.nix
freeradius.nix
gateone.nix
gdomap.nix
ghostunnel.nix nixos/ghostunnel: init 2021-05-20 10:41:52 +02:00
git-daemon.nix
gnunet.nix
go-neb.nix
go-shadowsocks2.nix
gobgpd.nix
gogoclient.nix
gvpe.nix
hans.nix
haproxy.nix
helpers.nix
hostapd.nix
htpdate.nix
i2p.nix
i2pd.nix
inspircd.nix
iodine.nix
iperf3.nix
iwd.nix
jicofo.nix
jitsi-videobridge.nix
keybase.nix
kippo.nix
knot.nix
kresd.nix nixos/kresd: tell resolveconf to use local resolver 2021-05-25 16:37:00 +02:00
lambdabot.nix
libreswan.nix nixos/libreswan: update for version 4.x 2021-05-18 08:13:36 +02:00
lldpd.nix
logmein-hamachi.nix
magic-wormhole-mailbox-server.nix
mailpile.nix
matterbridge.nix
minidlna.nix
miniupnpd.nix
miredo.nix
mjpg-streamer.nix
monero.nix nixos/monero: use isSystemUser = true 2021-05-08 02:13:25 +02:00
morty.nix
mosquitto.nix nixos/mosquitto: Migrate away from bind_address/port config keys 2021-05-01 19:46:48 +02:00
mstpd.nix
mtprotoproxy.nix
mullvad-vpn.nix
murmur.nix
mxisd.nix
namecoind.nix
nar-serve.nix
nat.nix
ncdns.nix
ndppd.nix
nebula.nix
networkmanager.nix nixos/networkmanager: Add connectionConfig. (#118308) 2021-06-08 11:13:59 -04:00
nextdns.nix
nftables.nix
ngircd.nix
nix-serve.nix
nix-store-gcs-proxy.nix
nixops-dns.nix
nntp-proxy.nix
nomad.nix
nsd.nix nixos/nsd: make nsd-checkconf work when configuration contains keys 2021-05-19 18:21:10 +02:00
ntopng.nix
nullidentdmod.nix
nylon.nix
ocserv.nix
ofono.nix
oidentd.nix
onedrive.nix
onedrive.xml
openfire.nix
openvpn.nix
ostinato.nix
owamp.nix
pdns-recursor.nix
pdnsd.nix
pixiecore.nix
pleroma.nix pleroma-otp: remove 2021-06-10 22:53:00 +02:00
pleroma.xml
polipo.nix
powerdns.nix
pppd.nix
pptpd.nix
prayer.nix
privoxy.nix
prosody.nix
prosody.xml
quassel.nix
quicktun.nix
quorum.nix
racoon.nix
radicale.nix nixos/radicale: harden systemd unit 2021-05-04 17:43:26 +02:00
radvd.nix
rdnssd.nix
redsocks.nix
resilio.nix
robustirc-bridge.nix
rpcbind.nix
rxe.nix
sabnzbd.nix
searx.nix nixos/searx: set settings.yml permissions using umask 2021-05-03 09:53:50 +02:00
shadowsocks.nix
shairport-sync.nix
shellhub-agent.nix
shorewall.nix
shorewall6.nix
shout.nix
skydns.nix
smartdns.nix
smokeping.nix
sniproxy.nix
softether.nix
solanum.nix nixos/solanum: implement reload and allow config changes 2021-06-16 00:19:35 +02:00
spacecookie.nix
spiped.nix
squid.nix
sslh.nix
strongswan.nix
stubby.nix
stunnel.nix
supplicant.nix
supybot.nix
syncplay.nix
syncthing-relay.nix
syncthing.nix
tailscale.nix tailscale: add interfaceName option 2021-06-14 11:25:08 +02:00
tcpcrypt.nix
teamspeak3.nix
tedicross.nix
tftpd.nix
thelounge.nix
tinc.nix
tinydns.nix
tox-bootstrapd.nix
tox-node.nix
toxvpn.nix
trickster.nix
tvheadend.nix
ucarp.nix nixos/ucarp: init 2021-06-15 18:13:31 +02:00
unbound.nix nixos/unbound: allow list of strings in top-level settings option type 2021-05-08 19:55:17 +02:00
unifi.nix
v2ray.nix
vsftpd.nix
wakeonlan.nix
wasabibackend.nix
websockify.nix
wg-quick.nix
wicd.nix
wireguard.nix nixos/wireguard: Remove .path systemd unit for privkey. Fixes #123203 2021-05-28 17:44:19 -07:00
wpa_supplicant.nix nixos/wireless: use udev to wait for interfaces 2021-08-12 00:31:06 +02:00
x2goserver.nix x2goserver: fix rename whole module 2021-06-11 09:07:23 +02:00
xandikos.nix
xinetd.nix
xl2tpd.nix
xrdp.nix nixos/xrdp: add openFirewall option 2021-06-11 08:13:48 +02:00
yggdrasil.nix nixos/yggdrasil: set directory permissions before writing keys 2021-05-08 09:49:19 +02:00
yggdrasil.xml
zerobin.nix
zeronet.nix
zerotierone.nix