NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.58k stars 13.06k forks source link

restartTriggers doesn't work for user services #246611

Open sg-qwt opened 11 months ago

sg-qwt commented 11 months ago

example:

      services.emacs = {
        enable = true;
      };

adding systemd.user.services.emacs.restartTriggers = [ ./init.el ]; will add X-Restart-Triggers to the user unit file.

But it won't have any effects or trigger any restarts on system rebuild.

nixos-options show thoes options exist, but looking into https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/activation/switch-to-configuration.pl, it seems doesn't take user services into account.

https://search.nixos.org/options?channel=unstable&show=systemd.user.services.%3Cname%3E.restartTriggers&from=0&size=50&sort=relevance&type=packages&query=systemd+triggers

jtrees commented 1 week ago

Thanks for documenting this. I've been debugging for a while. Was trying to figure out what's wrong with my config...

nixos-discourse commented 1 week ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cant-get-systemd-to-restart-my-units-on-change/34139/2

sg-qwt commented 1 week ago

Thanks for documenting this. I've been debugging for a while. Was trying to figure out what's wrong with my config...

btw, home manager has proper support for such use case. https://github.com/nix-community/home-manager/issues/5452

jtrees commented 1 week ago

@sg-qwt Sweet! I did not know about sd-switch. This is a sufficient workaround for me. Thanks for pointing me to it.