2016-10-21 22:04:48 +01:00
|
|
|
# NixOS module for Buildbot continous integration server.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.buildbot-master;
|
|
|
|
escapeStr = s: escape ["'"] s;
|
2017-01-30 17:44:14 +00:00
|
|
|
masterCfg = if cfg.masterCfg == null then pkgs.writeText "master.cfg" ''
|
2016-10-21 22:04:48 +01:00
|
|
|
from buildbot.plugins import *
|
|
|
|
factory = util.BuildFactory()
|
|
|
|
c = BuildmasterConfig = dict(
|
|
|
|
workers = [${concatStringsSep "," cfg.workers}],
|
2017-03-07 19:26:21 +00:00
|
|
|
protocols = { 'pb': {'port': ${toString cfg.bpPort} } },
|
2016-10-21 22:04:48 +01:00
|
|
|
title = '${escapeStr cfg.title}',
|
|
|
|
titleURL = '${escapeStr cfg.titleUrl}',
|
|
|
|
buildbotURL = '${escapeStr cfg.buildbotUrl}',
|
|
|
|
db = dict(db_url='${escapeStr cfg.dbUrl}'),
|
|
|
|
www = dict(port=${toString cfg.port}),
|
|
|
|
change_source = [ ${concatStringsSep "," cfg.changeSource} ],
|
|
|
|
schedulers = [ ${concatStringsSep "," cfg.schedulers} ],
|
|
|
|
builders = [ ${concatStringsSep "," cfg.builders} ],
|
|
|
|
status = [ ${concatStringsSep "," cfg.status} ],
|
|
|
|
)
|
|
|
|
for step in [ ${concatStringsSep "," cfg.factorySteps} ]:
|
|
|
|
factory.addStep(step)
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
2017-01-30 17:44:14 +00:00
|
|
|
''
|
2017-02-27 19:02:11 +00:00
|
|
|
else cfg.masterCfg;
|
2016-10-21 22:04:48 +01:00
|
|
|
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.buildbot-master = {
|
|
|
|
|
|
|
|
factorySteps = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "Factory Steps";
|
|
|
|
default = [];
|
|
|
|
example = [
|
|
|
|
"steps.Git(repourl='git://github.com/buildbot/pyflakes.git', mode='incremental')"
|
|
|
|
"steps.ShellCommand(command=['trial', 'pyflakes'])"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
changeSource = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "List of Change Sources.";
|
|
|
|
default = [];
|
|
|
|
example = [
|
|
|
|
"changes.GitPoller('git://github.com/buildbot/pyflakes.git', workdir='gitpoller-workdir', branch='master', pollinterval=300)"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the Buildbot continuous integration server.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Extra configuration to append to master.cfg";
|
2017-03-07 19:26:21 +00:00
|
|
|
default = "c['buildbotNetUsageData'] = None";
|
2016-10-21 22:04:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
masterCfg = mkOption {
|
2017-02-27 19:02:11 +00:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
description = "Optionally pass master.cfg path. Other options in this configuration will be ignored.";
|
2016-10-21 22:04:48 +01:00
|
|
|
default = null;
|
2017-02-27 19:02:11 +00:00
|
|
|
example = "/etc/nixos/buildbot/master.cfg";
|
2016-10-21 22:04:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
schedulers = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "List of Schedulers.";
|
|
|
|
default = [
|
|
|
|
"schedulers.SingleBranchScheduler(name='all', change_filter=util.ChangeFilter(branch='master'), treeStableTimer=None, builderNames=['runtests'])"
|
|
|
|
"schedulers.ForceScheduler(name='force',builderNames=['runtests'])"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
builders = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "List of Builders.";
|
|
|
|
default = [
|
2017-02-27 19:02:11 +00:00
|
|
|
"util.BuilderConfig(name='runtests',workernames=['example-worker'],factory=factory)"
|
2016-10-21 22:04:48 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
workers = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "List of Workers.";
|
2017-03-07 19:26:21 +00:00
|
|
|
default = [ "worker.Worker('example-worker', 'pass')" ];
|
2016-10-21 22:04:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
status = mkOption {
|
|
|
|
default = [];
|
|
|
|
type = types.listOf types.str;
|
|
|
|
description = "List of status notification endpoints.";
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
default = "buildbot";
|
|
|
|
type = types.str;
|
|
|
|
description = "User the buildbot server should execute under.";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "buildbot";
|
|
|
|
type = types.str;
|
|
|
|
description = "Primary group of buildbot user.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraGroups = mkOption {
|
|
|
|
type = types.listOf types.str;
|
2017-03-09 16:46:26 +00:00
|
|
|
default = [];
|
2016-10-21 22:04:48 +01:00
|
|
|
description = "List of extra groups that the buildbot user should be a part of.";
|
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
default = "/home/buildbot";
|
|
|
|
type = types.path;
|
|
|
|
description = "Buildbot home directory.";
|
|
|
|
};
|
|
|
|
|
|
|
|
buildbotDir = mkOption {
|
|
|
|
default = "${cfg.home}/master";
|
|
|
|
type = types.path;
|
|
|
|
description = "Specifies the Buildbot directory.";
|
|
|
|
};
|
|
|
|
|
|
|
|
bpPort = mkOption {
|
2017-03-07 19:26:21 +00:00
|
|
|
default = 9989;
|
|
|
|
type = types.int;
|
2016-10-21 22:04:48 +01:00
|
|
|
description = "Port where the master will listen to Buildbot Worker.";
|
|
|
|
};
|
|
|
|
|
|
|
|
listenAddress = mkOption {
|
|
|
|
default = "0.0.0.0";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the bind address on which the buildbot HTTP interface listens.";
|
|
|
|
};
|
|
|
|
|
|
|
|
buildbotUrl = mkOption {
|
|
|
|
default = "http://localhost:8010/";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the Buildbot URL.";
|
|
|
|
};
|
|
|
|
|
|
|
|
title = mkOption {
|
|
|
|
default = "Buildbot";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the Buildbot Title.";
|
|
|
|
};
|
|
|
|
|
|
|
|
titleUrl = mkOption {
|
|
|
|
default = "Buildbot";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the Buildbot TitleURL.";
|
|
|
|
};
|
|
|
|
|
|
|
|
dbUrl = mkOption {
|
|
|
|
default = "sqlite:///state.sqlite";
|
|
|
|
type = types.str;
|
|
|
|
description = "Specifies the database connection string.";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = 8010;
|
|
|
|
type = types.int;
|
|
|
|
description = "Specifies port number on which the buildbot HTTP interface listens.";
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
2017-03-07 19:26:21 +00:00
|
|
|
default = pkgs.buildbot-full;
|
|
|
|
defaultText = "pkgs.buildbot-full";
|
2017-02-27 19:02:11 +00:00
|
|
|
description = "Package to use for buildbot.";
|
2017-03-07 13:01:50 +00:00
|
|
|
example = literalExample "pkgs.buildbot-full";
|
2016-10-21 22:04:48 +01: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 ]";
|
2016-10-21 22:04:48 +01:00
|
|
|
type = types.listOf types.package;
|
|
|
|
description = "Packages to add to PATH for the buildbot process.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.extraGroups = optional (cfg.group == "buildbot") {
|
|
|
|
name = "buildbot";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraUsers = optional (cfg.user == "buildbot") {
|
|
|
|
name = "buildbot";
|
2017-01-30 17:44:14 +00:00
|
|
|
description = "Buildbot User.";
|
2016-10-21 22:04:48 +01:00
|
|
|
isNormalUser = true;
|
|
|
|
createHome = true;
|
|
|
|
home = cfg.home;
|
|
|
|
group = cfg.group;
|
|
|
|
extraGroups = cfg.extraGroups;
|
|
|
|
useDefaultShell = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.buildbot-master = {
|
2017-01-30 17:44:14 +00:00
|
|
|
description = "Buildbot Continuous Integration Server.";
|
2017-03-07 19:26:21 +00:00
|
|
|
after = [ "network-online.target" ];
|
2016-10-21 22:04:48 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = cfg.packages;
|
|
|
|
|
2017-03-07 19:26:21 +00:00
|
|
|
preStart = ''
|
|
|
|
env > envvars
|
|
|
|
mkdir -vp ${cfg.buildbotDir}
|
|
|
|
ln -sfv ${masterCfg} ${cfg.buildbotDir}/master.cfg
|
|
|
|
rm -fv $cfg.buildbotDir}/buildbot.tac
|
|
|
|
${cfg.package}/bin/buildbot create-master ${cfg.buildbotDir}
|
|
|
|
'';
|
|
|
|
|
2016-10-21 22:04:48 +01:00
|
|
|
serviceConfig = {
|
2017-03-10 05:02:49 +00:00
|
|
|
Type = "simple";
|
2016-10-21 22:04:48 +01:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
WorkingDirectory = cfg.home;
|
2017-07-05 17:00:22 +01:00
|
|
|
ExecStart = "${cfg.package}/bin/buildbot start --nodaemon ${cfg.buildbotDir}";
|
2017-03-07 19:26:21 +00:00
|
|
|
};
|
2016-10-21 22:04:48 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-05-23 05:02:23 +01:00
|
|
|
meta.maintainers = with lib.maintainers; [ nand0p mic92 ];
|
2017-01-30 17:44:14 +00:00
|
|
|
|
2016-10-21 22:04:48 +01:00
|
|
|
}
|