0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/services.buildbot-master: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:18:57 +02:00 committed by Jörg Thalheim
parent 2dc19bf4e0
commit d43e1678e7

View file

@ -1,9 +1,5 @@
# NixOS module for Buildbot continuous integration server. # NixOS module for Buildbot continuous integration server.
{ config, lib, options, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib;
let let
cfg = config.services.buildbot-master; cfg = config.services.buildbot-master;
opt = options.services.buildbot-master; opt = options.services.buildbot-master;
@ -11,27 +7,27 @@ let
package = pkgs.python3.pkgs.toPythonModule cfg.package; package = pkgs.python3.pkgs.toPythonModule cfg.package;
python = package.pythonModule; python = package.pythonModule;
escapeStr = escape [ "'" ]; escapeStr = lib.escape [ "'" ];
defaultMasterCfg = pkgs.writeText "master.cfg" '' defaultMasterCfg = pkgs.writeText "master.cfg" ''
from buildbot.plugins import * from buildbot.plugins import *
${cfg.extraImports} ${cfg.extraImports}
factory = util.BuildFactory() factory = util.BuildFactory()
c = BuildmasterConfig = dict( c = BuildmasterConfig = dict(
workers = [${concatStringsSep "," cfg.workers}], workers = [${lib.concatStringsSep "," cfg.workers}],
protocols = { 'pb': {'port': ${toString cfg.pbPort} } }, protocols = { 'pb': {'port': ${toString cfg.pbPort} } },
title = '${escapeStr cfg.title}', title = '${lib.escapeStr cfg.title}',
titleURL = '${escapeStr cfg.titleUrl}', titleURL = '${lib.escapeStr cfg.titleUrl}',
buildbotURL = '${escapeStr cfg.buildbotUrl}', buildbotURL = '${lib.escapeStr cfg.buildbotUrl}',
db = dict(db_url='${escapeStr cfg.dbUrl}'), db = dict(db_url='${lib.escapeStr cfg.dbUrl}'),
www = dict(port=${toString cfg.port}), www = dict(port=${toString cfg.port}),
change_source = [ ${concatStringsSep "," cfg.changeSource} ], change_source = [ ${lib.concatStringsSep "," cfg.changeSource} ],
schedulers = [ ${concatStringsSep "," cfg.schedulers} ], schedulers = [ ${lib.concatStringsSep "," cfg.schedulers} ],
builders = [ ${concatStringsSep "," cfg.builders} ], builders = [ ${lib.concatStringsSep "," cfg.builders} ],
services = [ ${concatStringsSep "," cfg.reporters} ], services = [ ${lib.concatStringsSep "," cfg.reporters} ],
configurators = [ ${concatStringsSep "," cfg.configurators} ], configurators = [ ${lib.concatStringsSep "," cfg.configurators} ],
) )
for step in [ ${concatStringsSep "," cfg.factorySteps} ]: for step in [ ${lib.concatStringsSep "," cfg.factorySteps} ]:
factory.addStep(step) factory.addStep(step)
${cfg.extraConfig} ${cfg.extraConfig}
@ -62,8 +58,8 @@ in {
options = { options = {
services.buildbot-master = { services.buildbot-master = {
factorySteps = mkOption { factorySteps = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = "Factory Steps"; description = "Factory Steps";
default = []; default = [];
example = [ example = [
@ -72,8 +68,8 @@ in {
]; ];
}; };
changeSource = mkOption { changeSource = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = "List of Change Sources."; description = "List of Change Sources.";
default = []; default = [];
example = [ example = [
@ -81,8 +77,8 @@ in {
]; ];
}; };
configurators = mkOption { configurators = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = "Configurator Steps, see https://docs.buildbot.net/latest/manual/configuration/configurators.html"; description = "Configurator Steps, see https://docs.buildbot.net/latest/manual/configuration/configurators.html";
default = []; default = [];
example = [ example = [
@ -90,35 +86,35 @@ in {
]; ];
}; };
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Whether to enable the Buildbot continuous integration server."; description = "Whether to enable the Buildbot continuous integration server.";
}; };
extraConfig = mkOption { extraConfig = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Extra configuration to append to master.cfg"; description = "Extra configuration to append to master.cfg";
default = "c['buildbotNetUsageData'] = None"; default = "c['buildbotNetUsageData'] = None";
}; };
extraImports = mkOption { extraImports = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Extra python imports to prepend to master.cfg"; description = "Extra python imports to prepend to master.cfg";
default = ""; default = "";
example = "from buildbot.process.project import Project"; example = "from buildbot.process.project import Project";
}; };
masterCfg = mkOption { masterCfg = lib.mkOption {
type = types.path; type = lib.types.path;
description = "Optionally pass master.cfg path. Other options in this configuration will be ignored."; description = "Optionally pass master.cfg path. Other options in this configuration will be ignored.";
default = defaultMasterCfg; default = defaultMasterCfg;
defaultText = literalMD ''generated configuration file''; defaultText = lib.literalMD ''generated configuration file'';
example = "/etc/nixos/buildbot/master.cfg"; example = "/etc/nixos/buildbot/master.cfg";
}; };
schedulers = mkOption { schedulers = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = "List of Schedulers."; description = "List of Schedulers.";
default = [ default = [
"schedulers.SingleBranchScheduler(name='all', change_filter=util.ChangeFilter(branch='master'), treeStableTimer=None, builderNames=['runtests'])" "schedulers.SingleBranchScheduler(name='all', change_filter=util.ChangeFilter(branch='master'), treeStableTimer=None, builderNames=['runtests'])"
@ -126,60 +122,60 @@ in {
]; ];
}; };
builders = mkOption { builders = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = "List of Builders."; description = "List of Builders.";
default = [ default = [
"util.BuilderConfig(name='runtests',workernames=['example-worker'],factory=factory)" "util.BuilderConfig(name='runtests',workernames=['example-worker'],factory=factory)"
]; ];
}; };
workers = mkOption { workers = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = "List of Workers."; description = "List of Workers.";
default = [ "worker.Worker('example-worker', 'pass')" ]; default = [ "worker.Worker('example-worker', 'pass')" ];
}; };
reporters = mkOption { reporters = lib.mkOption {
default = []; default = [];
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = "List of reporter objects used to present build status to various users."; description = "List of reporter objects used to present build status to various users.";
}; };
user = mkOption { user = lib.mkOption {
default = "buildbot"; default = "buildbot";
type = types.str; type = lib.types.str;
description = "User the buildbot server should execute under."; description = "User the buildbot server should execute under.";
}; };
group = mkOption { group = lib.mkOption {
default = "buildbot"; default = "buildbot";
type = types.str; type = lib.types.str;
description = "Primary group of buildbot user."; description = "Primary group of buildbot user.";
}; };
extraGroups = mkOption { extraGroups = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
description = "List of extra groups that the buildbot user should be a part of."; description = "List of extra groups that the buildbot user should be a part of.";
}; };
home = mkOption { home = lib.mkOption {
default = "/home/buildbot"; default = "/home/buildbot";
type = types.path; type = lib.types.path;
description = "Buildbot home directory."; description = "Buildbot home directory.";
}; };
buildbotDir = mkOption { buildbotDir = lib.mkOption {
default = "${cfg.home}/master"; default = "${cfg.home}/master";
defaultText = literalExpression ''"''${config.${opt.home}}/master"''; defaultText = lib.literalExpression ''"''${config.${opt.home}}/master"'';
type = types.path; type = lib.types.path;
description = "Specifies the Buildbot directory."; description = "Specifies the Buildbot directory.";
}; };
pbPort = mkOption { pbPort = lib.mkOption {
default = 9989; default = 9989;
type = types.either types.str types.int; type = lib.types.either lib.types.str lib.types.int;
example = "'tcp:9990:interface=127.0.0.1'"; example = "'tcp:9990:interface=127.0.0.1'";
description = '' description = ''
The buildmaster will listen on a TCP port of your choosing The buildmaster will listen on a TCP port of your choosing
@ -193,69 +189,69 @@ in {
''; '';
}; };
listenAddress = mkOption { listenAddress = lib.mkOption {
default = "0.0.0.0"; default = "0.0.0.0";
type = types.str; type = lib.types.str;
description = "Specifies the bind address on which the buildbot HTTP interface listens."; description = "Specifies the bind address on which the buildbot HTTP interface listens.";
}; };
buildbotUrl = mkOption { buildbotUrl = lib.mkOption {
default = "http://localhost:8010/"; default = "http://localhost:8010/";
type = types.str; type = lib.types.str;
description = "Specifies the Buildbot URL."; description = "Specifies the Buildbot URL.";
}; };
title = mkOption { title = lib.mkOption {
default = "Buildbot"; default = "Buildbot";
type = types.str; type = lib.types.str;
description = "Specifies the Buildbot Title."; description = "Specifies the Buildbot Title.";
}; };
titleUrl = mkOption { titleUrl = lib.mkOption {
default = "Buildbot"; default = "Buildbot";
type = types.str; type = lib.types.str;
description = "Specifies the Buildbot TitleURL."; description = "Specifies the Buildbot TitleURL.";
}; };
dbUrl = mkOption { dbUrl = lib.mkOption {
default = "sqlite:///state.sqlite"; default = "sqlite:///state.sqlite";
type = types.str; type = lib.types.str;
description = "Specifies the database connection string."; description = "Specifies the database connection string.";
}; };
port = mkOption { port = lib.mkOption {
default = 8010; default = 8010;
type = types.port; type = lib.types.port;
description = "Specifies port number on which the buildbot HTTP interface listens."; description = "Specifies port number on which the buildbot HTTP interface listens.";
}; };
package = mkPackageOption pkgs "buildbot-full" { package = lib.mkPackageOption pkgs "buildbot-full" {
example = "buildbot"; example = "buildbot";
}; };
packages = mkOption { packages = lib.mkOption {
default = [ pkgs.git ]; default = [ pkgs.git ];
defaultText = literalExpression "[ pkgs.git ]"; defaultText = lib.literalExpression "[ pkgs.git ]";
type = types.listOf types.package; type = lib.types.listOf lib.types.package;
description = "Packages to add to PATH for the buildbot process."; description = "Packages to add to PATH for the buildbot process.";
}; };
pythonPackages = mkOption { pythonPackages = lib.mkOption {
type = types.functionTo (types.listOf types.package); type = lib.types.functionTo (lib.types.listOf lib.types.package);
default = pythonPackages: with pythonPackages; [ ]; default = pythonPackages: with pythonPackages; [ ];
defaultText = literalExpression "pythonPackages: with pythonPackages; [ ]"; defaultText = lib.literalExpression "pythonPackages: with pythonPackages; [ ]";
description = "Packages to add the to the PYTHONPATH of the buildbot process."; description = "Packages to add the to the PYTHONPATH of the buildbot process.";
example = literalExpression "pythonPackages: with pythonPackages; [ requests ]"; example = lib.literalExpression "pythonPackages: with pythonPackages; [ requests ]";
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.groups = optionalAttrs (cfg.group == "buildbot") { users.groups = lib.optionalAttrs (cfg.group == "buildbot") {
buildbot = { }; buildbot = { };
}; };
users.users = optionalAttrs (cfg.user == "buildbot") { users.users = lib.optionalAttrs (cfg.user == "buildbot") {
buildbot = { buildbot = {
description = "Buildbot User."; description = "Buildbot User.";
isNormalUser = true; isNormalUser = true;
@ -298,8 +294,8 @@ in {
}; };
imports = [ imports = [
(mkRenamedOptionModule [ "services" "buildbot-master" "bpPort" ] [ "services" "buildbot-master" "pbPort" ]) (lib.mkRenamedOptionModule [ "services" "buildbot-master" "bpPort" ] [ "services" "buildbot-master" "pbPort" ])
(mkRemovedOptionModule [ "services" "buildbot-master" "status" ] '' (lib.mkRemovedOptionModule [ "services" "buildbot-master" "status" ] ''
Since Buildbot 0.9.0, status targets are deprecated and ignored. Since Buildbot 0.9.0, status targets are deprecated and ignored.
Review your configuration and migrate to reporters (available at services.buildbot-master.reporters). Review your configuration and migrate to reporters (available at services.buildbot-master.reporters).
'') '')