Skip to content

nixos: handle Systemd unit reload and restart triggers#114

Open
NotAShelf wants to merge 4 commits intomainfrom
notashelf/push-qsxstrtuykru
Open

nixos: handle Systemd unit reload and restart triggers#114
NotAShelf wants to merge 4 commits intomainfrom
notashelf/push-qsxstrtuykru

Conversation

@NotAShelf
Copy link
Copy Markdown
Member

@NotAShelf NotAShelf commented Mar 3, 2026

This is a port of my personal reload/restart trigger system, detached from the manifest parser that I ended up writing. Mostly streamlined, but the logic might not be as robust as we desire. Partially addresses #63

tl;dr: Introduces a new mechanism for automatically reloading or restarting systemd user units when their configuration changes. I've added test cases to make sure they actually work right, but there might be edge cases that I'm not actually seeing here.

@NotAShelf NotAShelf requested a review from eclairevoyant as a code owner March 3, 2026 20:42
Copy link
Copy Markdown
Contributor

@GetPsyched GetPsyched left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the tests, but the systemd service looks decent.

Thanks for working on this :)

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ie3cf2b807ff4f6d3d37faa819ed8b7c86a6a6964
@NotAShelf NotAShelf force-pushed the notashelf/push-qsxstrtuykru branch from 903393c to 0a4aa25 Compare March 8, 2026 16:54
@NotAShelf
Copy link
Copy Markdown
Member Author

Turns out the tests were failing because the strict checks were failing. Fixed.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I972768651f8597ecb847328c2bf23d4b6a6a6964
@NotAShelf NotAShelf force-pushed the notashelf/push-qsxstrtuykru branch from 0a4aa25 to 2e24d6e Compare March 8, 2026 16:57
@fxzzi
Copy link
Copy Markdown

fxzzi commented Mar 10, 2026

maybe i've set this up wrong but it seems to just reload the service every time. Here's an example service that seems to just restart even without changes

    hj = {
      xdg.data.files."walls".source = "${pins.walls}/images"; # wallpapers

      packages = [pkgs.hyprpaper];
      xdg.config.files."hypr/hyprpaper.conf" = {
        generator = self.lib.generators.toHyprlang {};
        value = {
          splash = 0;
          "wallpaper[]".path = "~/.local/state/wallpaper";
        };
      };

      systemd.services.hyprpaper = {
        description = "Hyprpaper wallpaper manager";
        after = ["graphical-session.target"];
        wantedBy = ["graphical-session.target"];
        partOf = ["graphical-session.target"];
        unitConfig = {
          ConditionEnvironment = "WAYLAND_DISPLAY";
        };
        serviceConfig = {
          Type = "simple";
          Restart = "always";
          ExecStart = "${getExe pkgs.hyprpaper}";
        };
        restartTriggers = [config.hj.xdg.config.files."hypr/hyprpaper.conf".source];
      };
    };

is that even how the restarTrigger should work? Do I need to write the actual path i.e. ~/.config/hypr/hyprpaper.conf? And should I add pkgs.hyprpaper in there also to make the systemd service restart on hyprpaper update or is that automatic?

@eclairevoyant
Copy link
Copy Markdown
Member

restartTriggers if written correctly should only fire if one of the paths listed has changed. I'll have to test more thoroughly this weekend.

@fxzzi
Copy link
Copy Markdown

fxzzi commented Mar 10, 2026

then something is definitely off on my end.

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I27a13f549cd3f3a395867c0a1d1058b86a6a6964
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I8e7f618c31eb4bc641bd51cd17d03e4f6a6a6964
@NotAShelf NotAShelf force-pushed the notashelf/push-qsxstrtuykru branch from 8001b6f to 554397e Compare March 24, 2026 10:10
@NotAShelf NotAShelf mentioned this pull request Mar 24, 2026
4 tasks
@fxzzi
Copy link
Copy Markdown

fxzzi commented Mar 24, 2026

latest changes got it working, seems to work perfectly for me :) adding the files i source, plus the package itself to the list, and the service will reload on changes to any of them.

thx :)

edit: also tested on my friends system. works perfectly

@NotAShelf
Copy link
Copy Markdown
Member Author

Thank you mr fazbear

Could be merged with @eclairevoyant's approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants