summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/buildbot/slave.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-11-11 01:34:18 +0100
committermakefu <github@syntax-fehler.de>2016-11-11 01:34:18 +0100
commit6c092cd20ca256b1cefa92aa779380cdb71c1313 (patch)
tree6bbc5631239a6ad65e790e499563bb1d65ffafc4 /krebs/3modules/buildbot/slave.nix
parent8161fcfe3a558b12fb2cf5dec135d26eadacd767 (diff)
buildbot: 0.8.4 -> 0.9.0rc2
Diffstat (limited to 'krebs/3modules/buildbot/slave.nix')
-rw-r--r--krebs/3modules/buildbot/slave.nix101
1 files changed, 35 insertions, 66 deletions
diff --git a/krebs/3modules/buildbot/slave.nix b/krebs/3modules/buildbot/slave.nix
index 650594a6c..95b547081 100644
--- a/krebs/3modules/buildbot/slave.nix
+++ b/krebs/3modules/buildbot/slave.nix
@@ -2,53 +2,21 @@
with import <stockholm/lib>;
let
- buildbot-slave-init = pkgs.writeText "buildbot-slave.tac" ''
- import os
-
- from buildslave.bot import BuildSlave
- from twisted.application import service
-
- basedir = '${cfg.workDir}'
- rotateLength = 10000000
- maxRotatedFiles = 10
-
- application = service.Application('buildslave')
-
- from twisted.python.logfile import LogFile
- from twisted.python.log import ILogObserver, FileLogObserver
- logfile = LogFile.fromFullPath(os.path.join(basedir, "twistd.log"), rotateLength=rotateLength,
- maxRotatedFiles=maxRotatedFiles)
- application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
-
- buildmaster_host = '${cfg.masterhost}'
- # TODO: masterport?
- port = 9989
- slavename = '${cfg.username}'
- passwd = '${cfg.password}'
- keepalive = 600
- usepty = 0
- umask = None
- maxdelay = 300
- allow_shutdown = None
-
- ${cfg.extraConfig}
-
- s = BuildSlave(buildmaster_host, port, slavename, passwd, basedir,
- keepalive, usepty, umask=umask, maxdelay=maxdelay,
- allow_shutdown=allow_shutdown)
- s.setServiceParent(application)
- '';
default-packages = [ pkgs.git pkgs.bash ];
- cfg = config.krebs.buildbot.slave;
+ buildbot = pkgs.stdenv.lib.overrideDerivation pkgs.buildbot-worker (old:{
+ patches = [ ./buildbot-worker.patch ];
+ propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.coreutils ];
+ });
+ cfg = config.krebs.buildbot.worker;
api = {
- enable = mkEnableOption "Buildbot Slave";
+ enable = mkEnableOption "Buildbot worker";
workDir = mkOption {
- default = "/var/lib/buildbot/slave";
+ default = "/var/lib/buildbot/worker";
type = types.str;
description = ''
- Path to build bot slave directory.
+ Path to build bot worker directory.
Will be created on startup.
'';
};
@@ -64,30 +32,30 @@ let
username = mkOption {
type = types.str;
description = ''
- slavename used to authenticate with master
+ workername used to authenticate with master
'';
};
password = mkOption {
type = types.str;
description = ''
- slave password used to authenticate with master
+ worker password used to authenticate with master
'';
};
contact = mkOption {
- default = "nix slave <buildslave@${config.networking.hostName}>";
+ default = "nix worker <buildworker@${config.networking.hostName}>";
type = types.str;
description = ''
- contact to be announced by buildslave
+ contact to be announced by buildworker
'';
};
description = mkOption {
- default = "Nix Generated BuildSlave";
+ default = "Nix Generated Buildworker";
type = types.str;
description = ''
- description for hostto be announced by buildslave
+ description for hostto be announced by buildworker
'';
};
@@ -95,7 +63,7 @@ let
default = [ pkgs.git ];
type = with types; listOf package;
description = ''
- packages which should be in path for buildslave
+ packages which should be in path for buildworker
'';
};
@@ -106,7 +74,7 @@ let
};
type = types.attrsOf types.str;
description = ''
- extra environment variables to be provided to the buildslave service
+ extra environment variables to be provided to the buildworker service
if you need nixpkgs, e.g. for running nix-shell you can set NIX_PATH here.
'';
};
@@ -119,26 +87,26 @@ let
keepalive = 600
'';
description = ''
- extra config evaluated before calling BuildSlave init in .tac file
+ extra config evaluated before calling Buildworker init in .tac file
'';
};
};
imp = {
- users.extraUsers.buildbotSlave = {
- uid = genid "buildbotSlave";
- description = "Buildbot Slave";
+ users.extraUsers.buildbotworker = {
+ uid = genid "buildbotworker";
+ description = "Buildbot worker";
home = cfg.workDir;
createHome = false;
};
- users.extraGroups.buildbotSlave = {
- gid = 1408105834;
+ users.extraGroups.buildbotworker = {
+ gid = genid "buildbotworker";
};
- systemd.services."buildbotSlave-${cfg.username}-${cfg.masterhost}" = {
- description = "Buildbot Slave for ${cfg.username}@${cfg.masterhost}";
+ systemd.services."buildbotworker-${cfg.username}-${cfg.masterhost}" = {
+ description = "Buildbot worker for ${cfg.username}@${cfg.masterhost}";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = default-packages ++ cfg.packages;
@@ -152,27 +120,28 @@ let
workdir = shell.escape cfg.workDir;
contact = shell.escape cfg.contact;
description = shell.escape cfg.description;
- buildbot = pkgs.buildbot-slave;
- # TODO:make this
+ masterhost = shell.escape cfg.masterhost;
+ username = shell.escape cfg.username;
+ password = shell.escape cfg.password;
in {
PermissionsStartOnly = true;
Type = "forking";
PIDFile = "${workdir}/twistd.pid";
- # TODO: maybe also prepare buildbot.tac?
- ExecStartPre = pkgs.writeDash "buildbot-master-init" ''
+ ExecStartPre = pkgs.writeDash "buildbot-slave-init" ''
set -efux
mkdir -p ${workdir}/info
- cp ${buildbot-slave-init} ${workdir}/buildbot.tac
+ # TODO: cleanup .tac file?
+ ${buildbot}/bin/buildbot-worker create-worker ${workdir} ${masterhost} ${username} ${password}
echo ${contact} > ${workdir}/info/admin
echo ${description} > ${workdir}/info/host
- chown buildbotSlave:buildbotSlave -R ${workdir}
+ chown buildbotworker:buildbotworker -R ${workdir}
chmod 700 -R ${workdir}
'';
- ExecStart = "${buildbot}/bin/buildslave start ${workdir}";
- ExecStop = "${buildbot}/bin/buildslave stop ${workdir}";
+ ExecStart = "${buildbot}/bin/buildbot-worker start ${workdir}";
+ ExecStop = "${buildbot}/bin/buildbot-worker stop ${workdir}";
PrivateTmp = "true";
- User = "buildbotSlave";
+ User = "buildbotworker";
Restart = "always";
RestartSec = "10";
};
@@ -180,6 +149,6 @@ let
};
in
{
- options.krebs.buildbot.slave = api;
+ options.krebs.buildbot.worker = api;
config = lib.mkIf cfg.enable imp;
}