/
srht-cronjobs.nix
43 lines (41 loc) · 1.01 KB
/
srht-cronjobs.nix
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ pkgs, lib, ... }:
let
doBuild = repo: pkgs.writeScript "doBuild.sh" ''
#! /usr/bin/env bash
set -eu
mkdir -p /tmp/overlaydir
cd /tmp/overlaydir
if [[ ! -d ./${repo} ]]; then
git clone https://github.com/colemickens/${repo}
fi
cd ${repo}
git remote update
git reset --hard origin/master
bash .ci/srht-submit.sh
'';
repos = [
"nixpkgs-wayland"
"flake-firefox-nightly"
];
genPrefixAttrs = prefix: names: f: lib.listToAttrs (map (n: lib.nameValuePair "${prefix}${n}" (f n)) names);
in
{
systemd.timers = genPrefixAttrs "srht-" repos (repo:
{
wantedBy = [ "timers.target" ];
partOf = [ "srht-${repo}.service" ];
timerConfig.OnCalendar = "hourly";
}
);
systemd.services = genPrefixAttrs "srht-" repos (repo:
{
path = with pkgs; [ bash curl jq git ];
after = [ "network.target" ];
serviceConfig = {
Type = "simple";
User = "cole";
ExecStart = ''${doBuild repo}'';
};
}
);
}