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
(nixos/systemd): Add Persistent for services. #123158
Conversation
Persistent will check on startup if a timer trigger was missed while the timer was inactive and trigger the timer once if it was. This is useful for computers to catch up on missed automated tasks from while they were shut down.
Some thoughts on this PR. I went with the current pattern of wrapping the option on the service configuration. I think it could also make sense to let you fully specify systemd.timers..timerConfig from the service, but this conflicts with the current pattern, and I would need more guidance on how to manage that. |
I'm not opposed to this change, but I'm not sure I see the value. I would have assumed this value is intended to be directly used by sysadmins for their own systemd units (presumably for discoverability, let people know this option exists, because it is a common problem to solve), but you explicitly mention other NixOS services utilizing this. Since other NixOS services often write their own systemd units I think it makes sense that NixOS developers likely know this systemd option exists already and there isn't much value. Just my thoughts, at least. cc @NixOS/systemd |
My end goal is just to enable Persistent for services.borgbackup.jobs, so whichever way is best to get that done I'm good with. Looking through a number of nixos services, they already configure both their systemd services through Some examples of startAt:
For these modules, adding this option gives them an easy way to make use of persistent without rewriting their module. In addition, it still takes a bit of dev work to take a nixos option, convert that into a string formatted for a systemd service or timer, then figure out what file to write that to so systemd picks it up. By using these options instead of directly writing the files, we can share that work between developers. But at the same time, I'm not an expert on nixos, so I'll go along with whatever people think is best. |
I'd feel more comfortable if the borgbackup/… modules could just access In fact, that's what
|
Ah thanks, I didn't find any examples of this, I should have been looking through the unstable options instead. Yeah, I like the idea of directly setting the service and the timer in the module. Seems like an better way to make all of the timer functionality available to a service. I'm going to close this PR and work on implementing that instead. |
Persistent will check on startup if a timer trigger was missed while the
timer was inactive and trigger the timer once if it was. This is useful
for computers to catch up on missed automated tasks from while they were
shut down.
Motivation for this change
This will enable us to provide the persistent option for system.autoUpgrade or services.borgbackup.jobs. That way, if you have a daily update or backup that is sometimes missed because your personal computer is off, it will catch up the next time you turn the computer on.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
). (I manually checked that the timer would work correctly for a service)nix path-info -S
before and after)