2016-10-21 22:04:48 +01:00
|
|
|
|
# NixOS module for Buildbot continous integration server.
|
|
|
|
|
|
2021-12-05 20:28:49 +00:00
|
|
|
|
{ config, lib, options, pkgs, ... }:
|
2016-10-21 22:04:48 +01:00
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
cfg = config.services.buildbot-master;
|
2021-12-05 20:28:49 +00:00
|
|
|
|
opt = options.services.buildbot-master;
|
2017-12-17 04:06:43 +00:00
|
|
|
|
|
|
|
|
|
python = cfg.package.pythonModule;
|
|
|
|
|
|
2016-10-21 22:04:48 +01:00
|
|
|
|
escapeStr = s: escape ["'"] s;
|
2017-12-17 04:06:43 +00:00
|
|
|
|
|
|
|
|
|
defaultMasterCfg = 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}],
|
2020-06-04 23:31:10 +01:00
|
|
|
|
protocols = { 'pb': {'port': ${toString cfg.pbPort} } },
|
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} ],
|
2020-06-18 15:32:43 +01:00
|
|
|
|
services = [ ${concatStringsSep "," cfg.reporters} ],
|
2016-10-21 22:04:48 +01:00
|
|
|
|
)
|
|
|
|
|
for step in [ ${concatStringsSep "," cfg.factorySteps} ]:
|
|
|
|
|
factory.addStep(step)
|
|
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
2017-12-17 04:06:43 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
tacFile = pkgs.writeText "buildbot-master.tac" ''
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
from twisted.application import service
|
|
|
|
|
from buildbot.master import BuildMaster
|
|
|
|
|
|
|
|
|
|
basedir = '${cfg.buildbotDir}'
|
|
|
|
|
|
|
|
|
|
configfile = '${cfg.masterCfg}'
|
|
|
|
|
|
|
|
|
|
# Default umask for server
|
|
|
|
|
umask = None
|
|
|
|
|
|
|
|
|
|
# note: this line is matched against to check that this is a buildmaster
|
|
|
|
|
# directory; do not edit it.
|
|
|
|
|
application = service.Application('buildmaster')
|
|
|
|
|
|
|
|
|
|
m = BuildMaster(basedir, configfile, umask)
|
|
|
|
|
m.setServiceParent(application)
|
|
|
|
|
'';
|
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-12-17 04:06:43 +00:00
|
|
|
|
type = types.path;
|
2017-02-27 19:02:11 +00:00
|
|
|
|
description = "Optionally pass master.cfg path. Other options in this configuration will be ignored.";
|
2017-12-17 04:06:43 +00:00
|
|
|
|
default = defaultMasterCfg;
|
2021-10-03 17:06:03 +01:00
|
|
|
|
defaultText = literalDocBook ''generated configuration file'';
|
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
|
|
|
|
};
|
|
|
|
|
|
2020-06-18 15:32:43 +01:00
|
|
|
|
reporters = mkOption {
|
2016-10-21 22:04:48 +01:00
|
|
|
|
default = [];
|
|
|
|
|
type = types.listOf types.str;
|
2020-06-18 15:32:43 +01:00
|
|
|
|
description = "List of reporter objects used to present build status to various users.";
|
2016-10-21 22:04:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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";
|
2021-12-05 20:28:49 +00:00
|
|
|
|
defaultText = literalExpression ''"''${config.${opt.home}}/master"'';
|
2016-10-21 22:04:48 +01:00
|
|
|
|
type = types.path;
|
|
|
|
|
description = "Specifies the Buildbot directory.";
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-04 23:31:10 +01:00
|
|
|
|
pbPort = mkOption {
|
2017-03-07 19:26:21 +00:00
|
|
|
|
default = 9989;
|
2020-06-04 23:31:10 +01:00
|
|
|
|
type = types.either types.str types.int;
|
|
|
|
|
example = "'tcp:9990:interface=127.0.0.1'";
|
|
|
|
|
description = ''
|
|
|
|
|
The buildmaster will listen on a TCP port of your choosing
|
|
|
|
|
for connections from workers.
|
|
|
|
|
It can also use this port for connections from remote Change Sources,
|
|
|
|
|
status clients, and debug tools.
|
|
|
|
|
This port should be visible to the outside world, and you’ll need to tell
|
|
|
|
|
your worker admins about your choice.
|
|
|
|
|
If put in (single) quotes, this can also be used as a connection string,
|
|
|
|
|
as defined in the <link xlink:href="https://twistedmatrix.com/documents/current/core/howto/endpoints.html">ConnectionStrings guide</link>.
|
|
|
|
|
'';
|
2016-10-21 22:04:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
2019-02-04 03:56:46 +00:00
|
|
|
|
default = pkgs.python3Packages.buildbot-full;
|
2021-10-03 17:06:03 +01:00
|
|
|
|
defaultText = literalExpression "pkgs.python3Packages.buildbot-full";
|
2017-02-27 19:02:11 +00:00
|
|
|
|
description = "Package to use for buildbot.";
|
2021-10-03 17:06:03 +01:00
|
|
|
|
example = literalExpression "pkgs.python3Packages.buildbot";
|
2016-10-21 22:04:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
packages = mkOption {
|
2017-12-17 04:06:43 +00:00
|
|
|
|
default = [ pkgs.git ];
|
2021-10-03 17:06:03 +01:00
|
|
|
|
defaultText = literalExpression "[ 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.";
|
|
|
|
|
};
|
2017-12-17 04:06:43 +00:00
|
|
|
|
|
|
|
|
|
pythonPackages = mkOption {
|
2021-01-31 22:36:28 +00:00
|
|
|
|
type = types.functionTo (types.listOf types.package);
|
2017-12-17 04:06:43 +00:00
|
|
|
|
default = pythonPackages: with pythonPackages; [ ];
|
2021-10-03 17:06:03 +01:00
|
|
|
|
defaultText = literalExpression "pythonPackages: with pythonPackages; [ ]";
|
2017-12-17 04:06:43 +00:00
|
|
|
|
description = "Packages to add the to the PYTHONPATH of the buildbot process.";
|
2021-10-03 17:06:03 +01:00
|
|
|
|
example = literalExpression "pythonPackages: with pythonPackages; [ requests ]";
|
2017-12-17 04:06:43 +00:00
|
|
|
|
};
|
2016-10-21 22:04:48 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2020-01-08 15:05:39 +00:00
|
|
|
|
users.groups = optionalAttrs (cfg.group == "buildbot") {
|
2019-09-14 18:51:29 +01:00
|
|
|
|
buildbot = { };
|
2016-10-21 22:04:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
|
users.users = optionalAttrs (cfg.user == "buildbot") {
|
|
|
|
|
buildbot = {
|
|
|
|
|
description = "Buildbot User.";
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
createHome = true;
|
|
|
|
|
home = cfg.home;
|
|
|
|
|
group = cfg.group;
|
|
|
|
|
extraGroups = cfg.extraGroups;
|
|
|
|
|
useDefaultShell = true;
|
|
|
|
|
};
|
2016-10-21 22:04:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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" ];
|
2017-12-17 04:06:43 +00:00
|
|
|
|
path = cfg.packages ++ cfg.pythonPackages python.pkgs;
|
|
|
|
|
environment.PYTHONPATH = "${python.withPackages (self: cfg.pythonPackages self ++ [ cfg.package ])}/${python.sitePackages}";
|
2016-10-21 22:04:48 +01:00
|
|
|
|
|
2017-03-07 19:26:21 +00:00
|
|
|
|
preStart = ''
|
2017-12-17 04:06:43 +00:00
|
|
|
|
mkdir -vp "${cfg.buildbotDir}"
|
|
|
|
|
# Link the tac file so buildbot command line tools recognize the directory
|
|
|
|
|
ln -sf "${tacFile}" "${cfg.buildbotDir}/buildbot.tac"
|
|
|
|
|
${cfg.package}/bin/buildbot create-master --db "${cfg.dbUrl}" "${cfg.buildbotDir}"
|
|
|
|
|
rm -f buildbot.tac.new master.cfg.sample
|
2017-03-07 19:26:21 +00:00
|
|
|
|
'';
|
|
|
|
|
|
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-12-17 04:06:43 +00:00
|
|
|
|
# NOTE: call twistd directly with stdout logging for systemd
|
|
|
|
|
ExecStart = "${python.pkgs.twisted}/bin/twistd -o --nodaemon --pidfile= --logfile - --python ${tacFile}";
|
2017-03-07 19:26:21 +00:00
|
|
|
|
};
|
2016-10-21 22:04:48 +01:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-04 23:31:10 +01:00
|
|
|
|
imports = [
|
|
|
|
|
(mkRenamedOptionModule [ "services" "buildbot-master" "bpPort" ] [ "services" "buildbot-master" "pbPort" ])
|
2020-06-18 15:32:43 +01:00
|
|
|
|
(mkRemovedOptionModule [ "services" "buildbot-master" "status" ] ''
|
|
|
|
|
Since Buildbot 0.9.0, status targets are deprecated and ignored.
|
|
|
|
|
Review your configuration and migrate to reporters (available at services.buildbot-master.reporters).
|
|
|
|
|
'')
|
2020-06-04 23:31:10 +01:00
|
|
|
|
];
|
|
|
|
|
|
2021-05-14 15:00:41 +01:00
|
|
|
|
meta.maintainers = with lib.maintainers; [ mic92 lopsided98 ];
|
2016-10-21 22:04:48 +01:00
|
|
|
|
}
|