Get to the login screen faster on NixOS

My configuration is pretty vanilla, I think, and it results in systemd dependencies from graphical.target on NetworkManager.service (by way of graphical.target -> multi-user.target -> network-setup.service -> network.target -> NetworkManager.service). NetworkManager is slow enough to start that I routinely see it blocking startup for several seconds (confirmed by systemd-analyze critical-chain).

Is there a standard way to configure NixOS so that my access to the login screen is as fast as possible? For example, it would cut off several seconds if I removed the dependency of graphical.target on NetworkManager.service, but the only way I know how to do this is brittle and error-prone, by surgically cutting edges in the graph. Is there a better way to do it?

1 Like

I think the core problem is systemd-user-sessions.service is ordered After=network.target, so essentially you can’t log in without network.
In the past it was even worse: multi-user.target was depending on networking-online.target, hanging everything for a couple of minutes when offline.

You could try overriding the units and checking with systemd-analyze critical-chain if you’ve got rid of the dependecies.

2 Likes

Oh no, it’s still there, I can’t believe it:

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

nixos/systemd: Temporarily bring back multi-user -> network-online · NixOS/nixpkgs@0d85bf0 · GitHub is the commit that reintroduced it.

1 Like

Yep, I’ll try to get rid of this as soon as possible.

10 Likes

Pull request here:

7 Likes

Merged, if everything goes well it should hit the nixos-unstabe channel in a few days. You can check the progress here.

Then you can try to see if the login actually speeds up or there is some other issue.

8 Likes