Author: rob
Date: Tue Jan 4 08:18:29 2011
New Revision: 25376
URL: https://svn.nixos.org/websvn/nix/?rev=25376&sc=1
Log:
initial hydra module
Added:
configurations/trunk/tud/hydra-module.nix
Modified:
configurations/trunk/tud/lucifer.nix
Added: configurations/trunk/tud/hydra-module.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ configurations/trunk/tud/hydra-module.nix Tue Jan 4 08:18:29 2011
(r25376)
@@ -0,0 +1,186 @@
+{ config, pkgs, ... }:
+
+with pkgs.lib;
+
+let
+ cfg = config.services.hydra;
+
+ hydraConf = pkgs.writeScript "hydra.conf" ''
+ using_frontend_proxy 1
+ base_uri ${cfg.hydraURL}
+ notification_sender ${cfg.notificationSender}
+ max_servers 25
+ '';
+
+ env = ''NIX_REMOTE=daemon HYDRA_DBI="${cfg.dbi}"
HYDRA_CONFIG=${cfg.baseDir}/data/hydra.conf HYDRA_DATA=${cfg.baseDir}/data'';
+in
+
+{
+ ###### interface
+ options = {
+ services.hydra = rec {
+
+ enable = mkOption {
+ default = false;
+ description = ''
+ Whether to run Hydra services.
+ '';
+ };
+
+ baseDir = mkOption {
+ default = ''/home/${user.default}'';
+ description = ''
+ The directory holding configuration, logs and temporary files.
+ '';
+ };
+
+ user = mkOption {
+ default = "hydra";
+ description = ''
+ The user the Hydra services should run as.
+ '';
+ };
+
+ dbi = mkOption {
+ default = "dbi:Pg:dbname=hydra;host=webdsl.org;user=hydra;";
+ description = ''
+ The DBI string for Hydra database connection
+ '';
+ };
+
+ hydraURL = mkOption {
+ default = "http://hydra.nixos.org";
+ description = ''
+ The base URL for the Hydra webserver instance. Used for links in
emails.
+ '';
+ };
+
+ minimumDiskFree = mkOption {
+ default = 5;
+ description = ''
+ Threshold of minimum disk space (G) to determine if queue runner
should run or not.
+ '';
+ };
+
+ minimumDiskFreeEvaluator = mkOption {
+ default = 2;
+ description = ''
+ Threshold of minimum disk space (G) to determine if evaluator should
run or not.
+ '';
+ };
+
+ notificationSender = mkOption {
+ default = "[email protected]";
+ description = ''
+ Sender email address used for email notifications.
+ '';
+ };
+ };
+
+ };
+
+
+ ###### implementation
+
+ config = mkIf cfg.enable {
+
+ users.extraUsers = [
+ { name = cfg.user;
+ description = "Hydra";
+ home = cfg.baseDir;
+ createHome = true;
+ useDefaultShell = true;
+ }
+ ];
+
+ nix.maxJobs = 0;
+ nix.distributedBuilds = true;
+ nix.manualNixMachines = true;
+ nix.useChroot = true;
+ nix.nrBuildUsers = 100;
+
+ nix.gc.automatic = true;
+ nix.gc.options = ''--max-freed "$((200 * 1024**3 - 1024 * $(df /nix/store
| tail -n 1 | awk '{ print $4 }')))"'';
+
+ nix.extraOptions = ''
+ gc-keep-outputs = true
+ gc-keep-derivations = true
+
+ # The default (`true') slows Nix down a lot since the build farm
+ # has so many GC roots.
+ gc-check-reachability = false
+
+ # Hydra needs caching of build failures.
+ build-cache-failure = true
+
+ build-poll-interval = 10
+
+ use-sqlite-wal = false
+ '';
+
+ jobs.hydra_init =
+ { description = "hydra-init";
+ startOn = "started network-interfaces";
+ preStart = ''
+ mkdir -p ${cfg.baseDir}/data
+ chown ${cfg.user} ${cfg.baseDir}/data
+ ln -sf ${hydraConf} ${cfg.baseDir}/data/hydra.conf
+ '';
+ exec = ''
+ echo done
+ '';
+ };
+
+ jobs.hydra_server =
+ { 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'
+ '';
+ };
+
+ jobs.hydra_queue_runner =
+ { description = "hydra-queue-runner";
+ startOn = "started network-interfaces hydra-init";
+ preStart = "${pkgs.su}/bin/su - ${cfg.user} -c 'hydra_queue_runner.pl
--unlock'";
+ exec = ''
+ ${pkgs.su}/bin/su - ${cfg.user} -c 'nice -n 8 hydra_queue_runner.pl
> ${cfg.baseDir}/data/queue_runner.log 2>&1'
+ '';
+ };
+
+ jobs.hydra_evaluator =
+ { description = "hydra-evaluator";
+ startOn = "started network-interfaces";
+ exec = ''
+ ${pkgs.su}/bin/su - ${cfg.user} -c '${env} nice -n 5
hydra_evaluator.pl > ${cfg.baseDir}/data/evaluator.log 2>&1'
+ '';
+ };
+
+ services.cron.systemCronJobs =
+ let
+ # If there is less than ... GiB of free disk space, stop the queue
+ # to prevent builds from failing or aborting.
+ checkSpace = pkgs.writeScript "hydra-check-space"
+ ''
+ #! /bin/sh
+ if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S'
/nix/store))) -lt $((${toString cfg.minimumDiskFree} * 1024**3)) ]; then
+ stop hydra-queue-runner
+ fi
+ if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S'
/nix/store))) -lt $((${toString cfg.minimumDiskFreeEvaluator} * 1024**3)) ];
then
+ stop hydra-evaluator
+ fi
+ '';
+ compressLogs = pkgs.writeScript "compress-logs" ''
+ #! /bin/sh -e
+ touch -d 'last month' r
+ find /nix/var/log/nix/drvs -type f -a ! -newer r -name '*.drv' |
xargs bzip2 -v
+ '';
+ 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"
+ ];
+
+ };
+}
+
Modified: configurations/trunk/tud/lucifer.nix
==============================================================================
--- configurations/trunk/tud/lucifer.nix Tue Jan 4 00:28:22 2011
(r25375)
+++ configurations/trunk/tud/lucifer.nix Tue Jan 4 08:18:29 2011
(r25376)
@@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
- require = [ ./common.nix ];
+ require = [ ./common.nix ./hydra-module.nix ];
nixpkgs.system = "x86_64-linux";
@@ -14,6 +14,8 @@
boot.initrd.kernelModules = [ "uhci_hcd" "ehci_hcd" "ata_piix"
"megaraid_sas" "usbhid" ];
boot.kernelModules = [ "acpi-cpufreq" "kvm-intel" ];
+ services.hydra.enable = true;
+
fileSystems =
[ { mountPoint = "/";
label = "nixos";
@@ -41,17 +43,10 @@
nixpkgs.config.subversion.pythonBindings = true;
- #services.hydraChannelMirror.enable = true;
+ services.hydraChannelMirror.enable = true;
+ services.hydraChannelMirror.enableBinaryPatches = true;
services.hydraChannelMirror.period = "0-59/15 * * * *";
-
- services.cron.systemCronJobs =
- [ "0-59/15 * * * * hydra-mirror ENABLE_PATCHES=1 perl
-I/home/hydra-mirror/nix/inst/libexec/nix ~/release/channels/mirror-channel.pl
http://hydra.nixos.org/jobset/nixpkgs/trunk/channel/latest
/data/releases/nixpkgs/channels/nixpkgs-unstable /data/releases/nars
http://nixos.org/releases/nars /data/releases/patches
http://nixos.org/releases/patches
http://hydra.nixos.org/job/nixpkgs/trunk/tarball/latest/download-by-type/file/source-dist
>> /var/log/nixpkgs-unstable.log 2>&1"
- ];
-
- /*
- services.httpd.enable = true;
- services.httpd.adminAddr = "[email protected]";
- */
+ services.hydraChannelMirror.dataDir = "/data/releases";
services.postgresql = {
enable = true;
@@ -67,9 +62,6 @@
'';
};
- nix.gc.automatic = true;
- nix.gc.options = "--max-freed $((100 * 1024**3))";
-
services.tomcat = {
enable = true;
baseDir = "/data/tomcat";
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits