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.

1 Like