-
Notifications
You must be signed in to change notification settings - Fork 39
Add systemd support for niri with hot reloading #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -122,6 +122,7 @@ let | |||||||||||||||||
| in | ||||||||||||||||||
| { | ||||||||||||||||||
| _class = "wrapper"; | ||||||||||||||||||
| imports = [ wlib.modules.systemd ]; | ||||||||||||||||||
| options = { | ||||||||||||||||||
| settings = lib.mkOption { | ||||||||||||||||||
| type = lib.types.submodule { | ||||||||||||||||||
|
|
@@ -304,13 +305,55 @@ in | |||||||||||||||||
| ''; | ||||||||||||||||||
| }; | ||||||||||||||||||
| }; | ||||||||||||||||||
| # Drop the upstream user unit; we ship our own (below) with ExecReload | ||||||||||||||||||
| # wired up to the niri IPC. Keep the desktop entry patched so display | ||||||||||||||||||
| # managers still pick up the wrapper's binary. | ||||||||||||||||||
| config.filesToExclude = [ | ||||||||||||||||||
| "lib/systemd/user/niri.service" | ||||||||||||||||||
| "share/systemd/user/niri.service" | ||||||||||||||||||
| ]; | ||||||||||||||||||
| config.filesToPatch = [ | ||||||||||||||||||
| "share/applications/*.desktop" | ||||||||||||||||||
| "share/systemd/user/niri.service" | ||||||||||||||||||
| ]; | ||||||||||||||||||
| config.package = config.pkgs.niri; | ||||||||||||||||||
| config.env = { | ||||||||||||||||||
| NIRI_CONFIG = toString config."config.kdl".path; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Shell-launched wrapper: same behaviour as upstream -- niri reads the | ||||||||||||||||||
| # immutable, build-pinned config straight from /nix/store. | ||||||||||||||||||
| config.env.NIRI_CONFIG = toString config."config.kdl".path; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Systemd-launched session: bootstrap a mutable runtime copy under | ||||||||||||||||||
| # $XDG_RUNTIME_DIR (systemd specifier %t) and point niri at it via | ||||||||||||||||||
| # `--config`. ExecReload re-stamps that file with the latest immutable | ||||||||||||||||||
| # snapshot and asks niri to re-read it via IPC, so config-only switches | ||||||||||||||||||
| # apply without dropping the session. | ||||||||||||||||||
|
Comment on lines
+324
to
+328
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
no longer relevant |
||||||||||||||||||
| config.systemd = { | ||||||||||||||||||
| description = "A scrollable-tiling Wayland compositor"; | ||||||||||||||||||
| bindsTo = [ "graphical-session.target" ]; | ||||||||||||||||||
| before = [ | ||||||||||||||||||
| "graphical-session.target" | ||||||||||||||||||
| "xdg-desktop-autostart.target" | ||||||||||||||||||
| ]; | ||||||||||||||||||
| wants = [ | ||||||||||||||||||
| "graphical-session-pre.target" | ||||||||||||||||||
| "xdg-desktop-autostart.target" | ||||||||||||||||||
| ]; | ||||||||||||||||||
| after = [ "graphical-session-pre.target" ]; | ||||||||||||||||||
| serviceConfig = { | ||||||||||||||||||
| Slice = "session.slice"; | ||||||||||||||||||
| Type = "notify"; | ||||||||||||||||||
| ExecStartPre = "${config.pkgs.coreutils}/bin/install -Dm644 ${config."config.kdl".path} %t/niri/config.kdl"; | ||||||||||||||||||
| ExecStart = "${config.exePath} --session --config %t/niri/config.kdl"; | ||||||||||||||||||
| ExecReload = [ | ||||||||||||||||||
| "${config.pkgs.coreutils}/bin/install -Dm644 ${config."config.kdl".path} %t/niri/config.kdl" | ||||||||||||||||||
| "${config.exePath} msg action load-config-file" | ||||||||||||||||||
| ]; | ||||||||||||||||||
|
Comment on lines
+344
to
+349
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
with niri 26.05 there is no reason to do mutable copies at the config file can just be relocated (infact i implemented that feature exactly for this reason in niri :) ) |
||||||||||||||||||
| }; | ||||||||||||||||||
| # Tell NixOS's switch-to-configuration to convert every "needs | ||||||||||||||||||
| # restart" verdict into `systemctl --user reload niri.service`, so | ||||||||||||||||||
| # config-only switches reload the live session via ExecReload instead | ||||||||||||||||||
| # of killing it. The flag is read out of the unit's [Service] section | ||||||||||||||||||
| # at switch time (X-ReloadIfChanged=true). | ||||||||||||||||||
| reloadIfChanged = true; | ||||||||||||||||||
| }; | ||||||||||||||||||
| config.meta.maintainers = [ | ||||||||||||||||||
| lib.maintainers.zimward | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be obvious. no point in having a LLM comment for it