2022-12-28 21:21:41 +00:00
|
|
|
|
# NixOS module for Buildbot continuous integration server.
|
2021-12-19 01:06:50 +00:00
|
|
|
|
{ config, lib, options, pkgs, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
let
|
|
|
|
|
cfg = config.services.buildbot-master;
|
2021-12-19 01:06:50 +00:00
|
|
|
|
opt = options.services.buildbot-master;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2023-04-12 12:48:02 +00:00
|
|
|
|
package = pkgs.python3.pkgs.toPythonModule cfg.package;
|
|
|
|
|
python = package.pythonModule;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
escapeStr = lib.escape [ "'" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
defaultMasterCfg = pkgs.writeText "master.cfg" ''
|
|
|
|
|
from buildbot.plugins import *
|
2023-10-09 19:29:22 +00:00
|
|
|
|
${cfg.extraImports}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
factory = util.BuildFactory()
|
|
|
|
|
c = BuildmasterConfig = dict(
|
2024-09-19 14:19:46 +00:00
|
|
|
|
workers = [${lib.concatStringsSep "," cfg.workers}],
|
2020-06-18 07:06:33 +00:00
|
|
|
|
protocols = { 'pb': {'port': ${toString cfg.pbPort} } },
|
2020-04-24 23:36:52 +00: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}),
|
2024-09-19 14:19:46 +00:00
|
|
|
|
change_source = [ ${lib.concatStringsSep "," cfg.changeSource} ],
|
|
|
|
|
schedulers = [ ${lib.concatStringsSep "," cfg.schedulers} ],
|
|
|
|
|
builders = [ ${lib.concatStringsSep "," cfg.builders} ],
|
|
|
|
|
services = [ ${lib.concatStringsSep "," cfg.reporters} ],
|
|
|
|
|
configurators = [ ${lib.concatStringsSep "," cfg.configurators} ],
|
2020-04-24 23:36:52 +00:00
|
|
|
|
)
|
2024-09-19 14:19:46 +00:00
|
|
|
|
for step in [ ${lib.concatStringsSep "," cfg.factorySteps} ]:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
factory.addStep(step)
|
|
|
|
|
|
|
|
|
|
${cfg.extraConfig}
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
options = {
|
|
|
|
|
services.buildbot-master = {
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
factorySteps = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Factory Steps";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [];
|
|
|
|
|
example = [
|
2022-03-30 09:31:56 +00:00
|
|
|
|
"steps.Git(repourl='https://github.com/buildbot/pyflakes.git', mode='incremental')"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
"steps.ShellCommand(command=['trial', 'pyflakes'])"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
changeSource = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "List of Change Sources.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [];
|
|
|
|
|
example = [
|
2022-03-30 09:31:56 +00:00
|
|
|
|
"changes.GitPoller('https://github.com/buildbot/pyflakes.git', workdir='gitpoller-workdir', branch='master', pollinterval=300)"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
configurators = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Configurator Steps, see https://docs.buildbot.net/latest/manual/configuration/configurators.html";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
default = [];
|
|
|
|
|
example = [
|
|
|
|
|
"util.JanitorConfigurator(logHorizon=timedelta(weeks=4), hour=12, dayOfWeek=6)"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
enable = lib.mkOption {
|
|
|
|
|
type = lib.types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Whether to enable the Buildbot continuous integration server.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
extraConfig = lib.mkOption {
|
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Extra configuration to append to master.cfg";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "c['buildbotNetUsageData'] = None";
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
extraImports = lib.mkOption {
|
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Extra python imports to prepend to master.cfg";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
default = "";
|
|
|
|
|
example = "from buildbot.process.project import Project";
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
masterCfg = lib.mkOption {
|
|
|
|
|
type = lib.types.path;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Optionally pass master.cfg path. Other options in this configuration will be ignored.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = defaultMasterCfg;
|
2024-09-19 14:19:46 +00:00
|
|
|
|
defaultText = lib.literalMD ''generated configuration file'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
example = "/etc/nixos/buildbot/master.cfg";
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
schedulers = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "List of Schedulers.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [
|
|
|
|
|
"schedulers.SingleBranchScheduler(name='all', change_filter=util.ChangeFilter(branch='master'), treeStableTimer=None, builderNames=['runtests'])"
|
|
|
|
|
"schedulers.ForceScheduler(name='force',builderNames=['runtests'])"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
builders = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "List of Builders.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [
|
|
|
|
|
"util.BuilderConfig(name='runtests',workernames=['example-worker'],factory=factory)"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
workers = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "List of Workers.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [ "worker.Worker('example-worker', 'pass')" ];
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
reporters = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [];
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "List of reporter objects used to present build status to various users.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
user = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "buildbot";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "User the buildbot server should execute under.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
group = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "buildbot";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Primary group of buildbot user.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
extraGroups = lib.mkOption {
|
|
|
|
|
type = lib.types.listOf lib.types.str;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "List of extra groups that the buildbot user should be a part of.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
home = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "/home/buildbot";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.path;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Buildbot home directory.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
buildbotDir = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "${cfg.home}/master";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
defaultText = lib.literalExpression ''"''${config.${opt.home}}/master"'';
|
|
|
|
|
type = lib.types.path;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Specifies the Buildbot directory.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
pbPort = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = 9989;
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.either lib.types.str lib.types.int;
|
2020-06-18 07:06:33 +00:00
|
|
|
|
example = "'tcp:9990:interface=127.0.0.1'";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = ''
|
2020-06-18 07:06:33 +00:00
|
|
|
|
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,
|
2022-08-12 12:06:08 +00:00
|
|
|
|
as defined in the [ConnectionStrings guide](https://twistedmatrix.com/documents/current/core/howto/endpoints.html).
|
2020-06-18 07:06:33 +00:00
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
listenAddress = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "0.0.0.0";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Specifies the bind address on which the buildbot HTTP interface listens.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
buildbotUrl = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "http://localhost:8010/";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Specifies the Buildbot URL.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
title = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "Buildbot";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Specifies the Buildbot Title.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
titleUrl = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "Buildbot";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Specifies the Buildbot TitleURL.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
dbUrl = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = "sqlite:///state.sqlite";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.str;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Specifies the database connection string.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
port = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = 8010;
|
2024-09-19 14:19:46 +00:00
|
|
|
|
type = lib.types.port;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Specifies port number on which the buildbot HTTP interface listens.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
package = lib.mkPackageOption pkgs "buildbot-full" {
|
2024-01-02 11:29:13 +00:00
|
|
|
|
example = "buildbot";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
packages = lib.mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = [ pkgs.git ];
|
2024-09-19 14:19:46 +00:00
|
|
|
|
defaultText = lib.literalExpression "[ pkgs.git ]";
|
|
|
|
|
type = lib.types.listOf lib.types.package;
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Packages to add to PATH for the buildbot process.";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
pythonPackages = lib.mkOption {
|
|
|
|
|
type = lib.types.functionTo (lib.types.listOf lib.types.package);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = pythonPackages: with pythonPackages; [ ];
|
2024-09-19 14:19:46 +00:00
|
|
|
|
defaultText = lib.literalExpression "pythonPackages: with pythonPackages; [ ]";
|
2024-04-21 15:54:59 +00:00
|
|
|
|
description = "Packages to add the to the PYTHONPATH of the buildbot process.";
|
2024-09-19 14:19:46 +00:00
|
|
|
|
example = lib.literalExpression "pythonPackages: with pythonPackages; [ requests ]";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
|
users.groups = lib.optionalAttrs (cfg.group == "buildbot") {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
buildbot = { };
|
|
|
|
|
};
|
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
|
users.users = lib.optionalAttrs (cfg.user == "buildbot") {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
buildbot = {
|
|
|
|
|
description = "Buildbot User.";
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
createHome = true;
|
2022-12-02 08:20:57 +00:00
|
|
|
|
inherit (cfg) home group extraGroups;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
useDefaultShell = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.services.buildbot-master = {
|
|
|
|
|
description = "Buildbot Continuous Integration Server.";
|
2024-01-25 14:12:00 +00:00
|
|
|
|
after = [ "network.target" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
path = cfg.packages ++ cfg.pythonPackages python.pkgs;
|
2023-04-12 12:48:02 +00:00
|
|
|
|
environment.PYTHONPATH = "${python.withPackages (self: cfg.pythonPackages self ++ [ package ])}/${python.sitePackages}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
|
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
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "simple";
|
|
|
|
|
User = cfg.user;
|
|
|
|
|
Group = cfg.group;
|
|
|
|
|
WorkingDirectory = cfg.home;
|
|
|
|
|
# NOTE: call twistd directly with stdout logging for systemd
|
2023-10-09 19:29:22 +00:00
|
|
|
|
ExecStart = "${python.pkgs.twisted}/bin/twistd -o --nodaemon --pidfile= --logfile - --python ${cfg.buildbotDir}/buildbot.tac";
|
|
|
|
|
# To reload on upgrade, set the following in your configuration:
|
|
|
|
|
# systemd.services.buildbot-master.reloadIfChanged = true;
|
|
|
|
|
ExecReload = [
|
|
|
|
|
"${pkgs.coreutils}/bin/ln -sf ${tacFile} ${cfg.buildbotDir}/buildbot.tac"
|
|
|
|
|
"${pkgs.coreutils}/bin/kill -HUP $MAINPID"
|
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
|
imports = [
|
2024-09-19 14:19:46 +00:00
|
|
|
|
(lib.mkRenamedOptionModule [ "services" "buildbot-master" "bpPort" ] [ "services" "buildbot-master" "pbPort" ])
|
|
|
|
|
(lib.mkRemovedOptionModule [ "services" "buildbot-master" "status" ] ''
|
2020-06-15 15:56:04 +00:00
|
|
|
|
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-18 07:06:33 +00:00
|
|
|
|
];
|
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
|
meta.maintainers = lib.teams.buildbot.members;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
}
|