svn path=/configurations/trunk/tud/; revision=28025
svn path=/configurations/trunk/tud/; revision=28025
Eelco Dolstra committed
Jul 31, 2011 at 22:17 UTC
50eedbc244b31ccc1b00a7a8e4dfbde27f914993
3 files changed
+131
-7
hydra-mirror.nix
new
+124
@@ -0,0 +1,124 @@
1
+{ config, pkgs, ... }:
2
+
3
+with pkgs.lib;
4
+
5
+let
6
+
7
+ cfg = config.services.hydraChannelMirror;
8
+
9
+ mirrorChannel = pkgs.fetchsvn {
10
+ url = https://svn.nixos.org/repos/nix/release/trunk/channels/mirror-channel.pl;
11
+ rev = 25210;
12
+ sha256 = "0gspqid1rpsj1z1mr29nakh7di278nlv6v2knafvmm3g8ah3yxgz";
13
+ };
14
+
15
+ cronjob = jobset:
16
+ "${cfg.period} ${cfg.user}"
17
+ + optionalString cfg.enableBinaryPatches " ENABLE_PATCHES=1"
18
+ + " perl -I${config.environment.nix}/libexec/nix -I${pkgs.perlPackages.DBI}/lib/perl5/site_perl -I${pkgs.perlPackages.DBDSQLite}/lib/perl5/site_perl ${mirrorChannel}"
19
+ + " ${cfg.hydraURL}/jobset/${jobset.project}/${jobset.jobset}/channel/latest"
20
+ + " ${cfg.dataDir}/${jobset.project}/channels/${jobset.name}"
21
+ + " ${cfg.dataDir}/nars"
22
+ + " ${cfg.mirrorURL}/nars"
23
+ + " ${cfg.dataDir}/patches"
24
+ + " ${cfg.mirrorURL}/patches"
25
+ + " ${if jobset.nixexprs == "" then "" else "${cfg.hydraURL}/job/${jobset.project}/${jobset.jobset}/${jobset.nixexprs}/latest/download-by-type/file/source-dist"}"
26
+ + " >> ${cfg.dataDir}/logs/${jobset.name}.log 2>&1\n";
27
+
28
+in
29
+
30
+{
31
+ options = {
32
+
33
+ services.hydraChannelMirror = {
34
+
35
+ enable = mkOption {
36
+ default = false;
37
+ description = ''
38
+ Whether to enable Hydra channel mirroring.
39
+ '';
40
+ };
41
+
42
+ period = mkOption {
43
+ default = "15 * * * *";
44
+ description = ''
45
+ This option defines (in the format used by cron) when the
46
+ mirroring should occur.
47
+ '';
48
+ };
49
+
50
+ user = mkOption {
51
+ default = "hydra-mirror";
52
+ description = ''
53
+ User running the Hydra mirror script.
54
+ '';
55
+ };
56
+
57
+ jobsets = mkOption {
58
+ default = [ { name = "nixpkgs-unstable"; project = "nixpkgs"; jobset = "trunk"; nixexprs = "tarball"; } ];
59
+ description = ''
60
+ List of jobsets to mirror.
61
+ '';
62
+ };
63
+
64
+ hydraURL = mkOption {
65
+ default = "http://hydra.nixos.org";
66
+ description = ''
67
+ Location (URL) of Hydra instance
68
+ '';
69
+ };
70
+
71
+ mirrorURL = mkOption {
72
+ default = "http://nixos.org/releases";
73
+ description = ''
74
+ Location (URL) of Hydra mirror
75
+ '';
76
+ };
77
+
78
+ dataDir = mkOption {
79
+ default = "/data/hydra-mirror";
80
+ description = ''
81
+ Location of Hydra mirror data
82
+ '';
83
+ };
84
+
85
+ enableBinaryPatches = mkOption {
86
+ default = false;
87
+ description = ''
88
+ Whether to enable generating binary patches for the mirrored channels.
89
+ '';
90
+ };
91
+ };
92
+
93
+ };
94
+
95
+ config = mkIf cfg.enable {
96
+
97
+ users.extraUsers = singleton
98
+ { name = cfg.user; description = "Hydra mirror"; };
99
+
100
+ services.cron.systemCronJobs = map cronjob cfg.jobsets;
101
+
102
+ system.activationScripts.hydraChannelMirror = stringAfter [ "stdio" "users" ]
103
+ ''
104
+ mkdir -m 0755 -p ${cfg.dataDir}
105
+ chown ${cfg.user} ${cfg.dataDir}
106
+
107
+ mkdir -m 0755 -p ${cfg.dataDir}/nars
108
+ chown ${cfg.user} ${cfg.dataDir}/nars
109
+
110
+ mkdir -m 0755 -p ${cfg.dataDir}/patches
111
+ chown ${cfg.user} ${cfg.dataDir}/patches
112
+
113
+ mkdir -m 0755 -p ${cfg.dataDir}/logs
114
+ chown ${cfg.user} ${cfg.dataDir}/logs
115
+
116
+ ${concatMapStrings (j : ''
117
+ mkdir -m 0755 -p ${cfg.dataDir}/${j.project}/channels/${j.name}
118
+ chown ${cfg.user} ${cfg.dataDir}/${j.project}/channels/${j.name}
119
+ '') cfg.jobsets}
120
+ '';
121
+
122
+ };
123
+
124
+}
hydra-module.nix
+6
-6
@@ -11,11 +11,11 @@ let
11
using_frontend_proxy 1
12
base_uri ${cfg.hydraURL}
13
notification_sender ${cfg.notificationSender}
14
- max_servers 25
14
+ max_servers 50
15
'';
16
17
- env = ''NIX_REMOTE=daemon HYDRA_DBI="${cfg.dbi}" HYDRA_CONFIG=${cfg.baseDir}/data/hydra.conf HYDRA_DATA=${cfg.baseDir}/data ''
18
- + ''HYDRA_TRACKER="${cfg.tracker}" '';
17
+ env = ''NIX_REMOTE=daemon HYDRA_DBI="${cfg.dbi}" HYDRA_CONFIG=${cfg.baseDir}/data/hydra.conf HYDRA_DATA=${cfg.baseDir}/data '';
18
+ server_env = env + ''HYDRA_TRACKER="${cfg.tracker}" '';
19
20
in
21
@@ -114,7 +114,7 @@ in
114
115
nix.gc.automatic = true;
116
# $3 / $4 don't always work depending on length of device name
117
- nix.gc.options = ''--max-freed "$((200 * 1024**3 - 1024 * $(df /nix/store | tail -n 1 | awk '{ print $3 }')))"'';
117
+ nix.gc.options = ''--max-freed "$((400 * 1024**3 - 1024 * $(df /nix/store | tail -n 1 | awk '{ print $3 }')))"'';
118
119
nix.extraOptions = ''
120
gc-keep-outputs = true
@@ -149,7 +149,7 @@ in
149
{ description = "hydra-server";
150
startOn = "started network-interfaces hydra-init";
151
exec = ''
152
- ${pkgs.su}/bin/su - ${cfg.user} -c '${env} hydra_server.pl > ${cfg.baseDir}/data/server.log 2>&1'
152
+ ${pkgs.su}/bin/su - ${cfg.user} -c '${server_env} hydra_server.pl > ${cfg.baseDir}/data/server.log 2>&1'
153
'';
154
};
155
@@ -192,7 +192,7 @@ in
192
in
193
[ "*/5 * * * * root ${checkSpace} &> ${cfg.baseDir}/data/checkspace.log"
194
"15 5 * * * root ${compressLogs} &> ${cfg.baseDir}/data/compress.log"
195
- "15 02 * * * ${cfg.user} ${env} hydra_update_gc_roots.pl &> ${cfg.baseDir}/data/gc-roots.log"
195
+ "15 02 * * * ${cfg.user} ${env} /home/${cfg.user}/.nix-profile/bin/hydra_update_gc_roots.pl &> ${cfg.baseDir}/data/gc-roots.log"
196
];
197
198
};
lucifer.nix
+1
-1
@@ -1,7 +1,7 @@
1
{ config, pkgs, ... }:
2
3
{
4
- require = [ ./common.nix ./hydra-module.nix ];
4
+ require = [ ./common.nix ./hydra-module.nix ./hydra-mirror.nix ];
5
6
nixpkgs.system = "x86_64-linux";
7