Nixos-rebuild switch --upgrade NetworkManager-wait-online.service failure

Dear Nixers,

When I run sudo nixos-rebuild switch --upgrade I get the following error:

activating the configuration...
setting up /etc...
reloading user units for freek...
setting up tmpfiles
warning: the following units failed: NetworkManager-wait-online.service

× NetworkManager-wait-online.service - Network Manager Wait Online
     Loaded: loaded (/etc/systemd/system/NetworkManager-wait-online.service; enabled; preset: enabled)
    Drop-In: /nix/store/bwp1df01a5kcmi8ylr1afdp61vj2rym4-system-units/NetworkManager-wait-online.service.d
     Active: failed (Result: exit-code) since Thu 2023-07-20 20:36:12 CEST; 58ms ago
   Duration: 5h 9min 32.773s
       Docs: man:nm-online(1)
    Process: 34161 ExecStart=/nix/store/6kf4ml6ziqwf1vrm1wmja8dbk3wnizcv-networkmanager-1.42.6/bin/nm-online -s -q (code=exited, status=1/FAILURE)
   Main PID: 34161 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 29ms

jul 20 20:35:12 nixos systemd[1]: Starting Network Manager Wait Online...
jul 20 20:36:12 nixos systemd[1]: NetworkManager-wait-online.service: Main process exited, code=exited, status=1/FAILURE
jul 20 20:36:12 nixos systemd[1]: NetworkManager-wait-online.service: Failed with result 'exit-code'.
jul 20 20:36:12 nixos systemd[1]: Failed to start Network Manager Wait Online.
warning: error(s) occurred while switching to the new configuration

I have discussed this on GitHub here: NetworkManager's nm-online kills nixos-rebuild · Issue #180175 · NixOS/nixpkgs · GitHub , I have not found any way to fix this.

Does anybody know how to do this?

The described problem is indeed fixed by:

{ = lib.mkForce false;

However for you this caused a second, unrelated problem, as lib was not in scope. I’m not sure of your setup so I cannot say exactly how to get lib, but this might work (lib is in pkgs):

{ = pkgs.lib.mkForce false;

Truth be told, I did not use lib.mkForce when using the workaround myself. So if that doesn’t work, you can simply try:

{ = false;
1 Like

As a non-expert, here are some of my observations…I often used to get this error

  1. Ignore it (sometime OK, depends on your next reboot…)
  2. If you repeat the rebuild it often works without issue (but there are implications of course…)
  3. nixos-rebuild boot and then reboot seems to avoid the issue.

Sometimes I find the switch is a bit wobbly, often not. So it depends on your stability requirements at the time. I now usually do “boot”, then reboot if I have the opportunity!

Hope that gives you something for thought…

1 Like

Yeah, that did it (the boot)! Thanx, good to know this as a noob, also makes sense (reboots are often required on other distro’s as well).