From 5c7bdcef039893d4da45ac8fd006f074c6d05397 Mon Sep 17 00:00:00 2001 From: r-vdp Date: Wed, 13 May 2026 12:10:25 +0200 Subject: [PATCH] nixos/niri: don't restart niri.service on switch The packaged user unit bakes the niri store path into ExecStart, so any rebuild of niri (including transitive dependency bumps) makes switch-to-configuration restart it, killing the graphical session. Mirror the display-manager modules and mark the unit restartIfChanged = false. Disable the default PATH injection so the generated drop-in does not override the environment imported by niri-session. --- nixos/modules/programs/wayland/niri.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nixos/modules/programs/wayland/niri.nix b/nixos/modules/programs/wayland/niri.nix index 05a9deadf33e..31cc485c4e00 100644 --- a/nixos/modules/programs/wayland/niri.nix +++ b/nixos/modules/programs/wayland/niri.nix @@ -40,6 +40,17 @@ in systemd.packages = [ cfg.package ]; + # Restarting the compositor kills the graphical session; same + # treatment as the display-manager modules. + systemd.user.services.niri = { + restartIfChanged = false; + # Defining the unit here generates a drop-in; without this it + # would carry the NixOS default Environment="PATH=coreutils:…", + # clobbering the PATH that niri-session imported into the user + # manager and breaking spawn actions that rely on it. + enableDefaultPath = false; + }; + xdg.portal = { enable = lib.mkDefault true;