Made timers their own module
This commit is contained in:
parent
b2687e271a
commit
270a739287
6 changed files with 89 additions and 37 deletions
40
modules/timers/backup.nix
Normal file
40
modules/timers/backup.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
inputs,
|
||||
outputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf mkOption types;
|
||||
cfg = config.horseman.timers.backup;
|
||||
homeCfg = config.horseman;
|
||||
in {
|
||||
options = {
|
||||
horseman.timers.backup = {
|
||||
enable = mkEnableOption "Enables the backup service";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assert homeCfg.network.syncthing || throw "Syncthing has not been enabled on this machine, refusing to add timer.";
|
||||
|
||||
systemd.timers."backupsyncthing" = {
|
||||
wantedby = ["timers.target"];
|
||||
timerconfig = {
|
||||
oncalendar = "weekly";
|
||||
persistent = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."backupsyncthing" = {
|
||||
script = ''
|
||||
/home/horseman/nix-config/misc/backup.sh
|
||||
'';
|
||||
serviceconfig = {
|
||||
type = "oneshot";
|
||||
user = "horseman";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue