2017-01-30 17:44:14 +00:00
|
|
|
# NixOS module for Buildbot Worker.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.buildbot-worker;
|
|
|
|
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.buildbot-worker = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the Buildbot Worker.";
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
default = "bbworker";
|
|
|
|
type = types.str;
|
|
|
|
description = "User the buildbot Worker should execute under.";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "bbworker";
|
|
|
|
type = types.str;
|
|
|
|
description = "Primary group of buildbot Worker user.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraGroups = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2017-03-09 16:46:26 +00:00
|
|
|
default = [];
|
2017-01-30 17:44:14 +00:00
|
|
|
description = "List of extra groups that the Buildbot Worker user should be a part of.";
|
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
default = "/home/bbworker";
|
|
|
|
type = types.path;
|
|
|
|
description = "Buildbot home directory.";
|
|
|
|
};
|
|
|
|
|
|
|
|
buildbotDir = mkOption {
|
|
|
|
default = "${cfg.home}/worker";
|
|
|
|
type = types.path;
|
|
|
|
description = "Specifies the Buildbot directory.";
|
|
|
|
};
|
|
|
|
|
|
|
|
workerUser = mkOption {
|
|
|
|
default = "example-worker";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the Buildbot Worker user.";
|
|
|
|
};
|
|
|
|
|
|
|
|
workerPass = mkOption {
|
|
|
|
default = "pass";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the Buildbot Worker password.";
|
|
|
|
};
|
|
|
|
|
|
|
|
masterUrl = mkOption {
|
|
|
|
default = "localhost:9989";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the Buildbot Worker connection string.";
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.buildbot-worker;
|
2017-03-07 13:01:50 +00:00
|
|
|
defaultText = "pkgs.buildbot-worker";
|
2017-01-30 17:44:14 +00:00
|
|
|
description = "Package to use for buildbot worker.";
|
2017-03-07 13:01:50 +00:00
|
|
|
example = literalExample "pkgs.buildbot-worker";
|
2017-01-30 17:44:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
packages = mkOption {
|
2017-03-07 19:26:21 +00:00
|
|
|
default = with pkgs; [ python27Packages.twisted git ];
|
2017-03-07 13:01:50 +00:00
|
|
|
example = literalExample "[ pkgs.git ]";
|
2017-01-30 17:44:14 +00:00
|
|
|
type = types.listOf types.package;
|
|
|
|
description = "Packages to add to PATH for the buildbot process.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups = optional (cfg.group == "bbworker") {
|
2017-01-30 17:44:14 +00:00
|
|
|
name = "bbworker";
|
|
|
|
};
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users = optional (cfg.user == "bbworker") {
|
2017-01-30 17:44:14 +00:00
|
|
|
name = "bbworker";
|
|
|
|
description = "Buildbot Worker User.";
|
|
|
|
isNormalUser = true;
|
|
|
|
createHome = true;
|
|
|
|
home = cfg.home;
|
|
|
|
group = cfg.group;
|
|
|
|
extraGroups = cfg.extraGroups;
|
|
|
|
useDefaultShell = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.buildbot-worker = {
|
|
|
|
description = "Buildbot Worker.";
|
2017-02-27 19:02:11 +00:00
|
|
|
after = [ "network.target" "buildbot-master.service" ];
|
2017-01-30 17:44:14 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = cfg.packages;
|
|
|
|
|
|
|
|
preStart = ''
|
2017-03-07 19:26:21 +00:00
|
|
|
mkdir -vp ${cfg.buildbotDir}
|
|
|
|
rm -fv $cfg.buildbotDir}/buildbot.tac
|
2017-01-30 17:44:14 +00:00
|
|
|
${cfg.package}/bin/buildbot-worker create-worker ${cfg.buildbotDir} ${cfg.masterUrl} ${cfg.workerUser} ${cfg.workerPass}
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
2017-03-10 05:02:49 +00:00
|
|
|
Type = "simple";
|
2017-01-30 17:44:14 +00:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
WorkingDirectory = cfg.home;
|
2017-03-07 19:26:21 +00:00
|
|
|
Environment = "PYTHONPATH=${cfg.package}/lib/python2.7/site-packages:${pkgs.python27Packages.future}/lib/python2.7/site-packages";
|
|
|
|
|
|
|
|
# NOTE: call twistd directly with stdout logging for systemd
|
|
|
|
#ExecStart = "${cfg.package}/bin/buildbot-worker start --nodaemon ${cfg.buildbotDir}";
|
|
|
|
ExecStart = "${pkgs.python27Packages.twisted}/bin/twistd -n -l - -y ${cfg.buildbotDir}/buildbot.tac";
|
2017-01-30 17:44:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ nand0p ];
|
|
|
|
|
|
|
|
}
|