/
hydra-mirror.nix
59 lines (50 loc) · 2.25 KB
/
hydra-mirror.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ config, lib, pkgs, ... }:
with lib;
let
channelScripts = import <nixos-channel-scripts> { inherit pkgs; };
makeUpdateChannel = channelName: mainJob:
{ timers."update-${channelName}" =
{ wantedBy = [ "timers.target" ];
timerConfig.OnUnitInactiveSec = 600;
timerConfig.OnBootSec = 900;
timerConfig.AccuracySec = 300;
};
services."update-${channelName}" =
{ description = "Update Channel ${channelName}";
after = [ "networking.target" ];
path = [ channelScripts ];
script =
''
# FIXME: use IAM role.
export AWS_ACCESS_KEY_ID=$(sed 's/aws_access_key_id=\(.*\)/\1/ ; t; d' ~/.aws/credentials)
export AWS_SECRET_ACCESS_KEY=$(sed 's/aws_secret_access_key=\(.*\)/\1/ ; t; d' ~/.aws/credentials)
exec mirror-nixos-branch ${channelName} https://hydra.nixos.org/job/${mainJob}/latest-finished
''; # */
serviceConfig.User = "hydra-mirror";
};
};
in
{
users.extraUsers.hydra-mirror =
{ description = "Channel mirroring user";
home = "/home/hydra-mirror";
isNormalUser = true;
openssh.authorizedKeys.keys = with import ../ssh-keys.nix; [ eelco rob ];
uid = 497;
};
systemd =
fold recursiveUpdate {} [
(makeUpdateChannel "nixos-18.09" "nixos/release-18.09/tested")
(makeUpdateChannel "nixos-18.09-small" "nixos/release-18.09-small/tested")
(makeUpdateChannel "nixos-18.03" "nixos/release-18.03/tested")
(makeUpdateChannel "nixos-18.03-small" "nixos/release-18.03-small/tested")
(makeUpdateChannel "nixos-17.09" "nixos/release-17.09/tested")
(makeUpdateChannel "nixos-17.09-small" "nixos/release-17.09-small/tested")
(makeUpdateChannel "nixos-unstable" "nixos/trunk-combined/tested")
(makeUpdateChannel "nixos-unstable-small" "nixos/unstable-small/tested")
(makeUpdateChannel "nixpkgs-18.09-darwin" "nixpkgs/nixpkgs-18.09-darwin/darwin-tested")
(makeUpdateChannel "nixpkgs-18.03-darwin" "nixpkgs/nixpkgs-18.03-darwin/darwin-tested")
(makeUpdateChannel "nixpkgs-17.09-darwin" "nixpkgs/nixpkgs-17.09-darwin/darwin-tested")
(makeUpdateChannel "nixpkgs-unstable" "nixpkgs/trunk/unstable")
];
}