2010-09-29 13:31:09 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
2010-12-20 15:14:29 +01:00
|
|
|
|
|
|
|
cfg = config.services.hydraChannelMirror;
|
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
mirrorChannel = pkgs.fetchsvn {
|
|
|
|
url = https://svn.nixos.org/repos/nix/release/trunk/channels/mirror-channel.pl;
|
2010-12-20 15:14:29 +01:00
|
|
|
rev = 25210;
|
|
|
|
sha256 = "0gspqid1rpsj1z1mr29nakh7di278nlv6v2knafvmm3g8ah3yxgz";
|
2010-09-29 13:31:09 +02:00
|
|
|
};
|
2010-12-20 15:14:29 +01:00
|
|
|
|
|
|
|
cronjob = jobset:
|
|
|
|
"${cfg.period} ${cfg.user}"
|
|
|
|
+ optionalString cfg.enableBinaryPatches " ENABLE_PATCHES=1"
|
2011-05-16 09:46:31 +02:00
|
|
|
+ " perl -I${config.environment.nix}/libexec/nix -I${pkgs.perlPackages.DBI}/lib/perl5/site_perl -I${pkgs.perlPackages.DBDSQLite}/lib/perl5/site_perl ${mirrorChannel}"
|
2010-12-20 15:14:29 +01:00
|
|
|
+ " ${cfg.hydraURL}/jobset/${jobset.project}/${jobset.jobset}/channel/latest"
|
|
|
|
+ " ${cfg.dataDir}/${jobset.project}/channels/${jobset.name}"
|
|
|
|
+ " ${cfg.dataDir}/nars"
|
|
|
|
+ " ${cfg.mirrorURL}/nars"
|
|
|
|
+ " ${cfg.dataDir}/patches"
|
|
|
|
+ " ${cfg.mirrorURL}/patches"
|
|
|
|
+ " ${if jobset.nixexprs == "" then "" else "${cfg.hydraURL}/job/${jobset.project}/${jobset.jobset}/${jobset.nixexprs}/latest/download-by-type/file/source-dist"}"
|
|
|
|
+ " >> ${cfg.dataDir}/logs/${jobset.name}.log 2>&1\n";
|
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
in
|
2010-12-20 15:14:29 +01:00
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
{
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.hydraChannelMirror = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable Hydra channel mirroring.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
period = mkOption {
|
|
|
|
default = "15 * * * *";
|
|
|
|
description = ''
|
|
|
|
This option defines (in the format used by cron) when the
|
|
|
|
mirroring should occur.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2010-12-20 15:14:29 +01:00
|
|
|
user = mkOption {
|
|
|
|
default = "hydra-mirror";
|
|
|
|
description = ''
|
|
|
|
User running the Hydra mirror script.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
jobsets = mkOption {
|
2010-12-20 15:14:29 +01:00
|
|
|
default = [ { name = "nixpkgs-unstable"; project = "nixpkgs"; jobset = "trunk"; nixexprs = "tarball"; } ];
|
2010-09-29 13:31:09 +02:00
|
|
|
description = ''
|
|
|
|
List of jobsets to mirror.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hydraURL = mkOption {
|
|
|
|
default = "http://hydra.nixos.org";
|
|
|
|
description = ''
|
|
|
|
Location (URL) of Hydra instance
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
mirrorURL = mkOption {
|
|
|
|
default = "http://nixos.org/releases";
|
|
|
|
description = ''
|
|
|
|
Location (URL) of Hydra mirror
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
default = "/data/hydra-mirror";
|
|
|
|
description = ''
|
|
|
|
Location of Hydra mirror data
|
|
|
|
'';
|
|
|
|
};
|
2010-12-20 15:14:29 +01:00
|
|
|
|
|
|
|
enableBinaryPatches = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable generating binary patches for the mirrored channels.
|
|
|
|
'';
|
|
|
|
};
|
2010-09-29 13:31:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2010-12-20 15:14:29 +01:00
|
|
|
users.extraUsers = singleton
|
2010-12-20 15:17:30 +01:00
|
|
|
{ name = cfg.user; description = "Hydra mirror"; };
|
2010-12-20 15:14:29 +01:00
|
|
|
|
|
|
|
services.cron.systemCronJobs = map cronjob cfg.jobsets;
|
2010-09-29 13:31:09 +02:00
|
|
|
|
|
|
|
system.activationScripts.hydraChannelMirror = stringAfter [ "stdio" "users" ]
|
|
|
|
''
|
|
|
|
mkdir -m 0755 -p ${cfg.dataDir}
|
2010-12-20 15:14:29 +01:00
|
|
|
chown ${cfg.user} ${cfg.dataDir}
|
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
mkdir -m 0755 -p ${cfg.dataDir}/nars
|
2010-12-20 15:14:29 +01:00
|
|
|
chown ${cfg.user} ${cfg.dataDir}/nars
|
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
mkdir -m 0755 -p ${cfg.dataDir}/patches
|
2010-12-20 15:14:29 +01:00
|
|
|
chown ${cfg.user} ${cfg.dataDir}/patches
|
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
mkdir -m 0755 -p ${cfg.dataDir}/logs
|
2010-12-20 15:14:29 +01:00
|
|
|
chown ${cfg.user} ${cfg.dataDir}/logs
|
|
|
|
|
2010-09-29 13:31:09 +02:00
|
|
|
${concatMapStrings (j : ''
|
2011-01-06 11:21:38 +01:00
|
|
|
mkdir -m 0755 -p ${cfg.dataDir}/${j.project}/channels/${j.name}
|
|
|
|
chown ${cfg.user} ${cfg.dataDir}/${j.project}/channels/${j.name}
|
2010-09-29 13:31:09 +02:00
|
|
|
'') cfg.jobsets}
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|