summaryrefslogtreecommitdiff
path: root/modules/git/cron.nix
blob: acb27bdebfeeb0a0666d4e0fd937f369d90a38ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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";
    };
  };
}