nix-config/modules/timers/backup.nix

34 lines
653 B
Nix

{
lib,
config,
...
}: let
inherit (lib) mkEnableOption mkIf;
cfg = config.horseman.timers.backup;
in {
options = {
horseman.timers.backup = {
enable = mkEnableOption "Enables the backup service";
};
};
config = mkIf cfg.enable {
systemd.timers."backupSyncthing" = {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "daily";
Persistent = true;
};
};
systemd.services."backupSyncthing" = {
script = ''
/home/horseman/nix-config/misc/backup.sh
'';
serviceConfig = {
Type = "oneshot";
User = "horseman";
};
};
};
}