May `nixos-rebuild switch` terminate a desktop environment session?

Running nixos-rebuild switch restarts services that it has updated. Does this also refer to the login manager and related services? If yes, can restarting such services result in a running desktop environment session (for example, GNOME session) being terminated?

I haven’t been logged out yet, unless I have changed my DE. There are always some services (e.g. gdm.service) which ln not restarted under normal circumstances. But if you are having a critical system, perhaps wait until someone more knowledgable answers your question.

1 Like

If you care, use nixos-rebuild boot see: How To: really atomic updates for NixOS - avoiding breakages

It should not. NixOS’s systemd submodule provides restartIfChanged to control this, which is set to false on things like the display-manager service unit. However, if you write a custom service unit that wants/requires an important part of your session (like your display manager), ensure it also has restartIfChanged = false; on it.

2 Likes

Actually I changed from LightDM to GDM yesterday with nixos-rebuild switch. The result was, that LightDM was stopped and my running desktop session terminated. GDM did not show up. Then I restarted the system using TTY.

My expected behavior is, that the switch would have been prohibited or LightDM would have been kept running.

Should I file a bug report? If yes against which module?

If you remove the module entirely it has no effect on your system and therefore cannot affect whether it is shut down or not. As far as NixOS is concerned, it does not exist, and never existed to begin with.

Your expected behavior isn’t really realistically feasible without state, which NixOS explicitly avoids.

Just… Don’t regularly switch display managers. You probably won’t switch more than once every few years after your initial experimentation, I don’t think this edge case is worth making our stateless deployment tool stateful.

1 Like