Why does `multi-user.target` depend on `network-online.target`?

in nixos/modules/system/boot/systemd.nix we have

systemd.targets.network-online.wantedBy = [ "multi-user.target" ];

Why is that necessary? Seems strange, and slows down my boot by ~3s (when I’m in reach of a known network; longer otherwise)


I’ve asked that myself, too. I don’t think any other distro does this.

Do you know if there’s a way to remove that dependency, short of forking nixpkgs? lib.mkForce does not seem to be an option for such global things, and I think there isn’t a lib.mkWithout or smth to remove a list member added elsewhere…

I’ve just disabled network online completely which replaces it with a noop.

a quick git blame reveals that it was removed, but then the change was reverted:

1 Like

Apparently someone tried to remove it and it broke a lot of services, which I will call out as already broken. I noticed several times that the getty was being delayed by DHCP trying to get a lease when offline, this is insane IMHO.


I agree this is a crazy reason to keep it like this. We should probably track down the broken services fix them instead.


Yeah, found that already. Reasoning sounds weak; so it’s that way because noone had time to fix it, it seems.

That works for me. Thank you.

Not a great situation overall, still.

1 Like

fyi: We are probably going to change this here because of systemd changes making it the right move: nixos/networkd: fix wait-online on networking.useDHCP default configuration by lf- · Pull Request #258345 · NixOS/nixpkgs · GitHub


PR attempting to remove the dependency:

I do hope we land that PR this week. It’d be great to have it for 23.11.

Though, note that the only reason this seems like it delays boot is because of this: Activating services that don't print to console delay services of Type=idle (like getty@.service) · Issue #28930 · systemd/systemd · GitHub

Basically, how long it takes to reach multi-user.target shouldn’t actually matter. Nothing actually waits for multi-user.target, so nothing should be delayed by multi-user.target depending on network-online.target. The exception is services with Type=idle, like getty. These services are delayed by a maximum of a few seconds if there are pending jobs (like network-online.target) when they should be started, so it does take a few seconds longer to reach a getty login. And systemd-analyze will tell you that boot took longer because multi-user.target took longer to reach, but again, this shouldn’t actually matter since nothing is actually delayed by this aside from Type=idle services.