Author: eelco
Date: Sun Jul 31 22:17:29 2011
New Revision: 28025
URL: https://svn.nixos.org/websvn/nix/?rev=28025&sc=1

Log:


Added:
   configurations/trunk/tud/hydra-mirror.nix
      - copied unchanged from r27548, 
nixos/trunk/modules/services/backup/hydra-mirror.nix
Modified:
   configurations/trunk/tud/hydra-module.nix
   configurations/trunk/tud/lucifer.nix

Copied: configurations/trunk/tud/hydra-mirror.nix (from r27548, 
nixos/trunk/modules/services/backup/hydra-mirror.nix)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ configurations/trunk/tud/hydra-mirror.nix   Sun Jul 31 22:17:29 2011        
(r28025, copy of r27548, nixos/trunk/modules/services/backup/hydra-mirror.nix)
@@ -0,0 +1,124 @@
+{ config, pkgs, ... }:
+
+with pkgs.lib;
+
+let 
+
+  cfg = config.services.hydraChannelMirror;
+
+  mirrorChannel = pkgs.fetchsvn {
+    url = 
https://svn.nixos.org/repos/nix/release/trunk/channels/mirror-channel.pl;
+    rev = 25210;
+    sha256 = "0gspqid1rpsj1z1mr29nakh7di278nlv6v2knafvmm3g8ah3yxgz";
+  };
+
+  cronjob = jobset:
+    "${cfg.period} ${cfg.user}"
+    + optionalString cfg.enableBinaryPatches " ENABLE_PATCHES=1"
+    + " perl -I${config.environment.nix}/libexec/nix 
-I${pkgs.perlPackages.DBI}/lib/perl5/site_perl 
-I${pkgs.perlPackages.DBDSQLite}/lib/perl5/site_perl ${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 = {
+  
+    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.
+        '';
+      };
+
+      user = mkOption {
+        default = "hydra-mirror";
+        description = ''
+          User running the Hydra mirror script.
+        '';
+      };
+
+      jobsets = mkOption {
+        default = [ { name = "nixpkgs-unstable"; project = "nixpkgs"; jobset = 
"trunk"; nixexprs = "tarball"; } ];
+        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
+        '';
+      };
+
+      enableBinaryPatches = mkOption {
+        default = false;
+        description = ''
+          Whether to enable generating binary patches for the mirrored 
channels.
+        '';
+      };
+    };
+
+  };
+
+  config = mkIf cfg.enable {
+  
+    users.extraUsers = singleton
+      { name = cfg.user; description = "Hydra mirror"; };
+
+    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
+        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}/${j.project}/channels/${j.name}
+          chown ${cfg.user} ${cfg.dataDir}/${j.project}/channels/${j.name}
+        '') cfg.jobsets}
+      '';
+    
+  };
+  
+}

Modified: configurations/trunk/tud/hydra-module.nix
==============================================================================
--- configurations/trunk/tud/hydra-module.nix   Sun Jul 31 22:00:29 2011        
(r28024)
+++ configurations/trunk/tud/hydra-module.nix   Sun Jul 31 22:17:29 2011        
(r28025)
@@ -11,11 +11,11 @@
       using_frontend_proxy 1
       base_uri ${cfg.hydraURL}
       notification_sender ${cfg.notificationSender}
-      max_servers 25
+      max_servers 50
     '';
     
-  env = ''NIX_REMOTE=daemon HYDRA_DBI="${cfg.dbi}" 
HYDRA_CONFIG=${cfg.baseDir}/data/hydra.conf HYDRA_DATA=${cfg.baseDir}/data ''
-      + ''HYDRA_TRACKER="${cfg.tracker}" '';
+  env = ''NIX_REMOTE=daemon HYDRA_DBI="${cfg.dbi}" 
HYDRA_CONFIG=${cfg.baseDir}/data/hydra.conf HYDRA_DATA=${cfg.baseDir}/data '';
+  server_env = env + ''HYDRA_TRACKER="${cfg.tracker}" '';
 
 in
 
@@ -114,7 +114,7 @@
       
     nix.gc.automatic = true;
     # $3 / $4 don't always work depending on length of device name
-    nix.gc.options = ''--max-freed "$((200 * 1024**3 - 1024 * $(df /nix/store 
| tail -n 1 | awk '{ print $3 }')))"'';
+    nix.gc.options = ''--max-freed "$((400 * 1024**3 - 1024 * $(df /nix/store 
| tail -n 1 | awk '{ print $3 }')))"'';
     
     nix.extraOptions = ''
       gc-keep-outputs = true
@@ -149,7 +149,7 @@
       { description = "hydra-server";
         startOn = "started network-interfaces hydra-init";
         exec = ''
-          ${pkgs.su}/bin/su - ${cfg.user} -c '${env} hydra_server.pl > 
${cfg.baseDir}/data/server.log 2>&1'
+          ${pkgs.su}/bin/su - ${cfg.user} -c '${server_env} hydra_server.pl > 
${cfg.baseDir}/data/server.log 2>&1'
         '';
       };
 
@@ -192,7 +192,7 @@
            in
            [ "*/5 * * * * root  ${checkSpace} &> 
${cfg.baseDir}/data/checkspace.log" 
              "15 5 * * * root  ${compressLogs} &> 
${cfg.baseDir}/data/compress.log"
-              "15 02 * * * ${cfg.user} ${env} hydra_update_gc_roots.pl &> 
${cfg.baseDir}/data/gc-roots.log"
+              "15 02 * * * ${cfg.user} ${env} 
/home/${cfg.user}/.nix-profile/bin/hydra_update_gc_roots.pl &> 
${cfg.baseDir}/data/gc-roots.log"
            ];
 
   };  

Modified: configurations/trunk/tud/lucifer.nix
==============================================================================
--- configurations/trunk/tud/lucifer.nix        Sun Jul 31 22:00:29 2011        
(r28024)
+++ configurations/trunk/tud/lucifer.nix        Sun Jul 31 22:17:29 2011        
(r28025)
@@ -1,7 +1,7 @@
 { config, pkgs, ... }:
 
 {
-  require = [ ./common.nix ./hydra-module.nix ];
+  require = [ ./common.nix ./hydra-module.nix ./hydra-mirror.nix ];
 
   nixpkgs.system = "x86_64-linux";
 
_______________________________________________
nix-commits mailing list
nix-comm...@cs.uu.nl
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to