Skip to content

Commit

Permalink
nixos/wpa_supplicant: finetune service dependencies
Browse files Browse the repository at this point in the history
The current requires/wantedBy dependencies present a number of problems,
especially for WiFi modules that might not be available at boot time
(which is when the boot will be delayed by the service timeout of
1m30s.) Removal of `wantedBy` in particular avoids such blocking from
taking place.

Furthermore, once the service fails to launch at boot for this reason,
the device appearing at a later date (most relevant to USB-pluggable
WiFi antennae,) the WPA supplicant wouldn't be launched, thus leaving
the user to figure out the service startups for themselves, which in the
worst case may be over network.

The `upheldBy` dependency type will ensure that the supplicant is
running for as long as the specified device exists, and the `bindsTo`
dependency type makes systemd stop the service if the WiFi device goes
away achieving the plug-and-play ideal. `upheldBy` here also replaces
the `wantedBy` as a mechanism for getting the service enabled and
started at all.
  • Loading branch information
nagisa committed Dec 20, 2024
1 parent c91d588 commit 293d7c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,15 @@

- `services.avahi.ipv6` now defaults to true.

- Per-interface `wpa_supplicant` systemd services generated by the `networking.wireless`
configuration no longer blocks the `multi-user.target` and will start/stop the unit on demand as
the specified wireless interface appears or disappears.

- `bind.cacheNetworks` now only controls access for recursive queries, where it previously controlled access for all queries.

- `programs.fzf.keybindings` now supports the fish shell.


<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

## Nixpkgs Library {#sec-release-25.05-lib}
Expand Down
7 changes: 4 additions & 3 deletions nixos/modules/services/networking/wpa_supplicant.nix
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ let
{
description = "WPA Supplicant instance" + optionalString (iface != null) " for interface ${iface}";

after = deviceUnit;
before = [ "network.target" ];
wants = [ "network.target" ];
requires = deviceUnit;
wantedBy = [ "multi-user.target" ];
after = deviceUnit;
bindsTo = deviceUnit;
upheldBy = deviceUnit;
wantedBy = optional (iface == null) "multi-user.target";
stopIfChanged = false;

path = [ pkgs.wpa_supplicant ];
Expand Down

0 comments on commit 293d7c6

Please sign in to comment.