hydra-module.nix: Give types to options

Also, rename the "service.hydra.hydra" option to
"service.hydra.package" to be consistent with NixOS option naming
conventions.
This commit is contained in:
Eelco Dolstra 2013-11-06 16:34:16 +01:00
parent 6fc59aa0da
commit ed69106c34

View file

@ -31,6 +31,7 @@ in
services.hydra = rec { services.hydra = rec {
enable = mkOption { enable = mkOption {
type = types.bool;
default = false; default = false;
description = '' description = ''
Whether to run Hydra services. Whether to run Hydra services.
@ -38,27 +39,28 @@ in
}; };
dbi = mkOption { dbi = mkOption {
type = types.string;
default = "dbi:Pg:dbname=hydra;host=localhost;user=hydra;"; default = "dbi:Pg:dbname=hydra;host=localhost;user=hydra;";
example = "dbi:SQLite:/home/hydra/db/hydra.sqlite";
description = '' description = ''
The DBI string for Hydra database connection. The DBI string for Hydra database connection.
''; '';
}; };
hydra = mkOption { package = mkOption {
type = types.path;
#default = pkgs.hydra; #default = pkgs.hydra;
description = '' description = "The Hydra package.";
Location of hydra
'';
}; };
hydraURL = mkOption { hydraURL = mkOption {
type = types.str;
description = '' description = ''
The base URL for the Hydra webserver instance. Used for links in emails. The base URL for the Hydra webserver instance. Used for links in emails.
''; '';
}; };
listenHost = mkOption { listenHost = mkOption {
type = types.str;
default = "*"; default = "*";
example = "localhost"; example = "localhost";
description = '' description = ''
@ -68,6 +70,7 @@ in
}; };
port = mkOption { port = mkOption {
type = types.int;
default = 3000; default = 3000;
description = '' description = ''
TCP port the web server should listen to. TCP port the web server should listen to.
@ -75,26 +78,30 @@ in
}; };
minimumDiskFree = mkOption { minimumDiskFree = mkOption {
type = types.int;
default = 5; default = 5;
description = '' description = ''
Threshold of minimum disk space (G) to determine if queue runner should run or not. Threshold of minimum disk space (GiB) to determine if queue runner should run or not.
''; '';
}; };
minimumDiskFreeEvaluator = mkOption { minimumDiskFreeEvaluator = mkOption {
type = types.int;
default = 2; default = 2;
description = '' description = ''
Threshold of minimum disk space (G) to determine if evaluator should run or not. Threshold of minimum disk space (GiB) to determine if evaluator should run or not.
''; '';
}; };
notificationSender = mkOption { notificationSender = mkOption {
type = types.str;
description = '' description = ''
Sender email address used for email notifications. Sender email address used for email notifications.
''; '';
}; };
tracker = mkOption { tracker = mkOption {
type = types.str;
default = ""; default = "";
description = '' description = ''
Piece of HTML that is included on all pages. Piece of HTML that is included on all pages.
@ -102,6 +109,7 @@ in
}; };
logo = mkOption { logo = mkOption {
type = types.nullOr types.str;
default = null; default = null;
description = '' description = ''
File name of an alternate logo to be displayed on the web pages. File name of an alternate logo to be displayed on the web pages.
@ -109,8 +117,8 @@ in
}; };
debugServer = mkOption { debugServer = mkOption {
default = false;
type = types.bool; type = types.bool;
default = false;
description = "Whether to run the server in debug mode"; description = "Whether to run the server in debug mode";
}; };
@ -135,7 +143,7 @@ in
max_servers 25 max_servers 25
''; '';
environment.systemPackages = [ cfg.hydra ]; environment.systemPackages = [ cfg.package ];
users.extraUsers.hydra = users.extraUsers.hydra =
{ description = "Hydra"; { description = "Hydra";
@ -184,7 +192,7 @@ in
chmod 600 ${baseDir}/.pgpass-tmp chmod 600 ${baseDir}/.pgpass-tmp
mv ${baseDir}/.pgpass-tmp ${baseDir}/.pgpass mv ${baseDir}/.pgpass-tmp ${baseDir}/.pgpass
fi fi
${pkgs.shadow}/bin/su hydra -c ${cfg.hydra}/bin/hydra-init ${pkgs.shadow}/bin/su hydra -c ${cfg.package}/bin/hydra-init
''; '';
serviceConfig.Type = "oneshot"; serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true; serviceConfig.RemainAfterExit = true;
@ -196,7 +204,7 @@ in
after = [ "hydra-init.service" ]; after = [ "hydra-init.service" ];
environment = serverEnv; environment = serverEnv;
serviceConfig = serviceConfig =
{ ExecStart = "@${cfg.hydra}/bin/hydra-server hydra-server -f -h '${cfg.listenHost}' --max_spare_servers 5 --max_servers 25 --max_requests 100${optionalString cfg.debugServer " -d"}"; { ExecStart = "@${cfg.package}/bin/hydra-server hydra-server -f -h '${cfg.listenHost}' --max_spare_servers 5 --max_servers 25 --max_requests 100${optionalString cfg.debugServer " -d"}";
User = "hydra"; User = "hydra";
Restart = "always"; Restart = "always";
}; };
@ -209,8 +217,8 @@ in
path = [ pkgs.nettools ]; path = [ pkgs.nettools ];
environment = env; environment = env;
serviceConfig = serviceConfig =
{ ExecStartPre = "${cfg.hydra}/bin/hydra-queue-runner --unlock"; { ExecStartPre = "${cfg.package}/bin/hydra-queue-runner --unlock";
ExecStart = "@${cfg.hydra}/bin/hydra-queue-runner hydra-queue-runner"; ExecStart = "@${cfg.package}/bin/hydra-queue-runner hydra-queue-runner";
User = "hydra"; User = "hydra";
Restart = "always"; Restart = "always";
}; };
@ -223,7 +231,7 @@ in
path = [ pkgs.nettools ]; path = [ pkgs.nettools ];
environment = env; environment = env;
serviceConfig = serviceConfig =
{ ExecStart = "@${cfg.hydra}/bin/hydra-evaluator hydra-evaluator"; { ExecStart = "@${cfg.package}/bin/hydra-evaluator hydra-evaluator";
User = "hydra"; User = "hydra";
Restart = "always"; Restart = "always";
}; };
@ -234,7 +242,7 @@ in
after = [ "hydra-init.service" ]; after = [ "hydra-init.service" ];
environment = env; environment = env;
serviceConfig = serviceConfig =
{ ExecStart = "@${cfg.hydra}/bin/hydra-update-gc-roots hydra-update-gc-roots"; { ExecStart = "@${cfg.package}/bin/hydra-update-gc-roots hydra-update-gc-roots";
User = "hydra"; User = "hydra";
}; };
}; };