Open rycee opened 2 months ago
Enabled, so far so good on my side.
@drupol Thanks, that's good 🙂
@rycee I have noticed a small behavior change since switching to sd-switch
. When I stop a user unit declared with home-manager, and then do a nixos-rebuild switch
the unit starts again which didn't happen before.
@Janik-Haag Thanks for the feedback. This is probably an effect of sd-switch not starting new services directly, rather it starts all active targets. Doing it that way makes systemd figure out which of the new service units should be started and starts them.
Starting the target also starts stopped services, which is what you see. Shouldn't be terribly tricky to fix. I'll make sd-switch do the figuring out and start parts instead.
@Janik-Haag I've released a new version of sd-switch that is a bit more restrictive about starting unmanaged services. It will still start up managed services that are wanted by an active target, though. I'm not certain there is much that can be done about that since I don't know of a good way to detect "manually stopped" from "not running for other reasons". The new version should be available in all channels now.
I don't know of a good way to detect "manually stopped" from "not running for other reasons".
That sounds like an interesting and tricky problem, can you share more details?
Would it make sense for sd-switch
to use the following logic:
By the way, I noticed that sd-switch
is described as a "third party application". But isn't it technically first-party, since it was created by the author of home-manager? :slightly_smiling_face:
My use case is simple but using sd-switch
works perfectly for it. The default method failed to restart the service when my config changed.
Here's my config snippet:
systemd.user.services.hyprpaper = {
Unit = {
Description = "desktop wallpaper";
X-Restart-Triggers = [ "${config.home-manager.users.foo.xdg.configFile.hyprpaper.source}" ];
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
ExecStart = lib.getExe pkgs.hyprpaper;
};
};
Thanks!
Description
With version 0.4.0 of sd-switch, it should be more robust and work out of the box for most people. We should therefore switch to using it by default.
Sd-switch is a tool that automatically starts/stops/reloads systemd services when activating a Home Manager configuration.
You can use it today by adding
systemd.user.startServices = "sd-switch"
to your configuration. If it works well for you then consider adding a thumbs up reaction to this issue. If it does not work OK, then please add a comment outlining the issue you have. Make sure you have an up-to-date version of Nixpkgs unstable.