forked from mirrors/nixpkgs
updated hydra mirror module
svn path=/nixos/trunk/; revision=25211
This commit is contained in:
parent
747e284e75
commit
5d7b524bd3
|
@ -3,16 +3,30 @@
|
|||
with pkgs.lib;
|
||||
|
||||
let
|
||||
cfg = config.services.hydraChannelMirror ;
|
||||
|
||||
cfg = config.services.hydraChannelMirror;
|
||||
|
||||
mirrorChannel = pkgs.fetchsvn {
|
||||
url = https://svn.nixos.org/repos/nix/release/trunk/channels/mirror-channel.pl;
|
||||
rev = 24132;
|
||||
sha256 = "02xvswbbr2sj9k1wfraa0j9053vf6w88nhk15qwzs8nkm180n820";
|
||||
rev = 25210;
|
||||
sha256 = "0gspqid1rpsj1z1mr29nakh7di278nlv6v2knafvmm3g8ah3yxgz";
|
||||
};
|
||||
cronjob = jobset : ''
|
||||
${cfg.period} root ENABLE_PATCHES=1 PATH=${config.environment.nix}/libexec/nix:$PATH perl -I${config.environment.nix}/libexec/nix ${mirrorChannel} ${cfg.hydraURL}/jobset/${jobset.project}/${jobset.jobset}/channel/latest ${cfg.dataDir}/channels/${jobset.relURL} ${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
|
||||
'';
|
||||
|
||||
cronjob = jobset:
|
||||
"${cfg.period} ${cfg.user}"
|
||||
+ optionalString cfg.enableBinaryPatches " ENABLE_PATCHES=1"
|
||||
+ " perl -I${config.environment.nix}/libexec/nix ${mirrorChannel}"
|
||||
+ " ${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";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
|
||||
|
@ -33,8 +47,15 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
default = "hydra-mirror";
|
||||
description = ''
|
||||
User running the Hydra mirror script.
|
||||
'';
|
||||
};
|
||||
|
||||
jobsets = mkOption {
|
||||
default = [ rec { name = "nixpkgs-unstable"; project = "nixpkgs"; jobset = "trunk"; nixexprs = "tarball"; relURL = "nixpkgs/channels/${name}"; } ];
|
||||
default = [ { name = "nixpkgs-unstable"; project = "nixpkgs"; jobset = "trunk"; nixexprs = "tarball"; } ];
|
||||
description = ''
|
||||
List of jobsets to mirror.
|
||||
'';
|
||||
|
@ -60,25 +81,41 @@ in
|
|||
Location of Hydra mirror data
|
||||
'';
|
||||
};
|
||||
|
||||
enableBinaryPatches = mkOption {
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable generating binary patches for the mirrored channels.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
services.cron.systemCronJobs = map cronjob cfg.jobsets ;
|
||||
users.extraUsers = singleton
|
||||
{ name = cfg.user; };
|
||||
|
||||
services.cron.systemCronJobs = map cronjob cfg.jobsets;
|
||||
|
||||
system.activationScripts.hydraChannelMirror = stringAfter [ "stdio" "users" ]
|
||||
''
|
||||
mkdir -m 0755 -p ${cfg.dataDir}
|
||||
chown ${cfg.user} ${cfg.dataDir}
|
||||
|
||||
mkdir -m 0755 -p ${cfg.dataDir}/nars
|
||||
chown ${cfg.user} ${cfg.dataDir}/nars
|
||||
|
||||
mkdir -m 0755 -p ${cfg.dataDir}/patches
|
||||
mkdir -m 0755 -p ${cfg.dataDir}/channels
|
||||
ln -fs ${cfg.dataDir}/nars ${cfg.dataDir}/channels/nars
|
||||
ln -fs ${cfg.dataDir}/patches ${cfg.dataDir}/channels/patches
|
||||
chown ${cfg.user} ${cfg.dataDir}/patches
|
||||
|
||||
mkdir -m 0755 -p ${cfg.dataDir}/logs
|
||||
chown ${cfg.user} ${cfg.dataDir}/logs
|
||||
|
||||
${concatMapStrings (j : ''
|
||||
mkdir -m 0755 -p ${cfg.dataDir}/channels/${j.relURL}
|
||||
mkdir -m 0755 -p ${cfg.dataDir}/{j.project}/channels/${j.name}
|
||||
chown ${cfg.user} ${cfg.dataDir}/{j.project}/channels/${j.name}
|
||||
'') cfg.jobsets}
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue