OK so this is a bit emberrasing, as I’m using NixOS for more then a year and only now I’ve stopped to think that maybe my current usage of systemd services is not good.
So basically, if I run
systemctl --user enable <this> I can enable user systemd services provided by packages. This creates a symlinks such as:
lrwxrwxrwx 1 doron developers 95 Jun 12 13:31 default.target.wants/pulseaudio.service -> /nix/store/j9sg853np8czrvdsfg6qdbmn599h3370-pulseaudio-13.0/lib/systemd/user/pulseaudio.service lrwxrwxrwx 1 doron developers 95 Jun 12 13:31 pulseaudio.service -> /nix/store/j9sg853np8czrvdsfg6qdbmn599h3370-pulseaudio-13.0/lib/systemd/user/pulseaudio.service
But as you can see, the symlinks are absolute, meaning that
nix-collect-garbage -d might remove kill the symlinks and then I’ll have to run
systemctl --user reenable pulseaudio, not to mention the fact that the service that the symlink targets to, probably points in
ExecStart= to the binary of the old pulseaudio…
The workaround I thought of was a script that will run
systemctl --user reenable for every service I enable. And I have to run this script after every time I collect garbage.
But that’s absurd right? I could create the symlinks by myself and point them to
/run/current-system/ but that means I’m not enjoying
systemctl. Is it possible to use the system’s
configuration.nix to do declaratively do it? Or perhaps there’s a nicer way to handle these symlinks?
I’d like to avoid using
home-manager because it’s features are too bloat for me.