From a333c097c87c8b450bcdeb8bbccbd254db958a72 Mon Sep 17 00:00:00 2001 From: Raghuram Subramani Date: Wed, 15 Oct 2025 10:21:00 -0400 Subject: cron->timer-update-timestamps --- modules/git/cron.nix | 28 ---------------------------- modules/git/timer-backup.nix | 26 ++++++++++++++++++++++++++ modules/git/timer-update-timestamps.nix | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 28 deletions(-) delete mode 100644 modules/git/cron.nix create mode 100644 modules/git/timer-backup.nix create mode 100644 modules/git/timer-update-timestamps.nix (limited to 'modules') diff --git a/modules/git/cron.nix b/modules/git/cron.nix deleted file mode 100644 index acb27bd..0000000 --- a/modules/git/cron.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - systemd.timers."update-timestamps" = { - wantedBy = [ "timers.target" ]; - timerConfig = { - OnBootSec = "10s"; - OnUnitActiveSec = "10s"; - Unit = "update-timestamps.service"; - }; - }; - - systemd.services."update-timestamps" = { - script = '' - REPOSITORIES=$(find /home/git/* -name '*.git' -type d) - - for repo in $REPOSITORIES; do - cd $repo - mkdir -p info/web - echo $(${pkgs.git}/bin/git log -1 --date=iso --format=%ci) > info/web/last-modified - done - ''; - serviceConfig = { - Type = "oneshot"; - User = "git"; - }; - }; -} diff --git a/modules/git/timer-backup.nix b/modules/git/timer-backup.nix new file mode 100644 index 0000000..42c227d --- /dev/null +++ b/modules/git/timer-backup.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +{ + systemd.timers."backup-repositories" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + Unit = "backup-repositories.service"; + }; + }; + + systemd.services."backup-repositories" = { + script = '' + mkdir -p $HOME/backups + + REPOSITORIES=$(find /home/git/* -name '*.git' -type d) + + ''; + + serviceConfig = { + Type = "oneshot"; + User = "git"; + }; + }; +} diff --git a/modules/git/timer-update-timestamps.nix b/modules/git/timer-update-timestamps.nix new file mode 100644 index 0000000..acb27bd --- /dev/null +++ b/modules/git/timer-update-timestamps.nix @@ -0,0 +1,28 @@ +{ config, lib, pkgs, ... }: + +{ + systemd.timers."update-timestamps" = { + wantedBy = [ "timers.target" ]; + timerConfig = { + OnBootSec = "10s"; + OnUnitActiveSec = "10s"; + Unit = "update-timestamps.service"; + }; + }; + + systemd.services."update-timestamps" = { + script = '' + REPOSITORIES=$(find /home/git/* -name '*.git' -type d) + + for repo in $REPOSITORIES; do + cd $repo + mkdir -p info/web + echo $(${pkgs.git}/bin/git log -1 --date=iso --format=%ci) > info/web/last-modified + done + ''; + serviceConfig = { + Type = "oneshot"; + User = "git"; + }; + }; +} -- cgit v1.2.3