Skip to content

Instantly share code, notes, and snippets.

@nand0p
Last active July 7, 2017 17:03
Show Gist options
  • Save nand0p/fe2f52d94374618550d07697cec6f85a to your computer and use it in GitHub Desktop.
Save nand0p/fe2f52d94374618550d07697cec6f85a to your computer and use it in GitHub Desktop.
buildbot-mod
# NixOS module for Buildbot continous integration server.
# Full file at https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/continuous-integration/buildbot/master.nix
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.buildbot-master;
escapeStr = s: escape ["'"] s;
masterCfg = if cfg.masterCfg == null then pkgs.writeText "master.cfg" ''
from buildbot.plugins import *
factory = util.BuildFactory()
c = BuildmasterConfig = dict(
workers = [${concatStringsSep "," cfg.workers}],
protocols = { 'pb': {'port': ${toString cfg.bpPort} } },
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}
''
else cfg.masterCfg;
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'])"
];
};
...
systemd.services.buildbot-master = {
description = "Buildbot Continuous Integration Server.";
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
path = cfg.packages;
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}
'';
serviceConfig = {
Type = "simple";
User = cfg.user;
Group = cfg.group;
WorkingDirectory = cfg.home;
ExecStart = "${cfg.package}/bin/buildbot start --nodaemon ${cfg.buildbotDir}";
};
};
};
meta.maintainers = with lib.maintainers; [ nand0p mic92 ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment