nix-configs

Personal NixOS and home-manager configuration files
Log | Files | Refs

commit e0b78afd37508ec615b24617d602856c64de8680
parent 0a3ab78e6a4e8729eed6b4f248a1f4d771567717
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Thu, 28 May 2026 16:13:16 +0100

Attempt to move restic to systemd timers

Diffstat:
Mmachines/artemis.nix | 1-
Mmachines/ilias.nix | 10----------
Mscripts/restic.nix | 21++++++++++++++++++++-
3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/machines/artemis.nix b/machines/artemis.nix @@ -52,7 +52,6 @@ let machine = "artemis"; in { "*/10 * * * * ${vars.user.username} magnets" "*/10 * * * * ${vars.user.username} stagit-generate" "55 23 * * SUN ${vars.user.username} blog-duolingo" - "0 */12 * * * ${vars.user.username} backup-cloud" ]; }; diff --git a/machines/ilias.nix b/machines/ilias.nix @@ -69,16 +69,6 @@ let machine = "ilias"; in { { device = "/dev/disk/by-uuid/3397e636-91db-44ae-9572-923e4b3acbbe"; } ]; - # Cron jobs - services = { - cron = { - enable = true; - systemCronJobs = [ - "0 */12 * * * ${vars.user.username} backup-cloud" - ]; - }; - }; - # Packages environment.systemPackages = with pkgs; [ czkawka # duplicate file finder diff --git a/scripts/restic.nix b/scripts/restic.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, vars, ... }: let backup-cloud = pkgs.writeShellScriptBin "backup-cloud" '' @@ -23,4 +23,23 @@ let ''; in { environment.systemPackages = [ backup-cloud ]; + + systemd.services.backup-cloud = { + description = "Restic cloud backup"; + serviceConfig = { + Type = "oneshot"; + User = vars.user.username; + ExecStart = "${backup-cloud}/bin/backup-cloud"; + }; + }; + + systemd.timers.backup-cloud = { + description = "Run backup-cloud every 12 hours at a random offset"; + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "*-*-* 00/12:00:00"; + RandomizedDelaySec = "6h"; + Persistent = true; + }; + }; }