2017-07-27 17:45:45 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
with import <stockholm/lib>;
|
|
|
|
let
|
|
|
|
cfg = config.krebs.ci;
|
|
|
|
|
|
|
|
hostname = config.networking.hostName;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.krebs.ci = {
|
|
|
|
enable = mkEnableOption "krebs continous integration";
|
2017-08-09 16:14:04 +00:00
|
|
|
stockholmSrc = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "http://cgit.${hostname}.r/stockholm";
|
|
|
|
};
|
2017-07-30 17:05:55 +00:00
|
|
|
treeStableTimer = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 10;
|
|
|
|
description = "how long to wait until we test changes (in minutes)";
|
|
|
|
};
|
2017-08-31 17:01:53 +00:00
|
|
|
hosts = mkOption {
|
|
|
|
type = types.listOf types.host;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
List of hosts that should be build
|
|
|
|
'';
|
2017-07-27 17:45:45 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts.build = {
|
|
|
|
serverAliases = [ "build.${hostname}.r" ];
|
|
|
|
locations."/".extraConfig = ''
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_pass http://127.0.0.1:${toString config.krebs.buildbot.master.web.port};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
krebs.buildbot.master = {
|
|
|
|
slaves = {
|
|
|
|
testslave = "lasspass";
|
|
|
|
};
|
|
|
|
change_source.stockholm = ''
|
2017-08-09 16:14:04 +00:00
|
|
|
stockholm_repo = '${cfg.stockholmSrc}'
|
2017-07-27 17:45:45 +00:00
|
|
|
cs.append(
|
|
|
|
changes.GitPoller(
|
|
|
|
stockholm_repo,
|
|
|
|
workdir='stockholm-poller', branches=True,
|
|
|
|
project='stockholm',
|
|
|
|
pollinterval=10
|
|
|
|
)
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
scheduler = {
|
|
|
|
build-scheduler = ''
|
|
|
|
# build all hosts
|
|
|
|
sched.append(
|
|
|
|
schedulers.SingleBranchScheduler(
|
|
|
|
change_filter=util.ChangeFilter(branch_re=".*"),
|
2017-07-30 17:05:55 +00:00
|
|
|
treeStableTimer=${toString cfg.treeStableTimer}*60,
|
2017-07-27 17:45:45 +00:00
|
|
|
name="build-all-branches",
|
|
|
|
builderNames=[
|
|
|
|
"build-hosts"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
force-scheduler = ''
|
|
|
|
sched.append(
|
|
|
|
schedulers.ForceScheduler(
|
|
|
|
name="force",
|
|
|
|
builderNames=[
|
|
|
|
"build-hosts"
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
builder_pre = ''
|
|
|
|
# prepare grab_repo step for stockholm
|
|
|
|
grab_repo = steps.Git(
|
|
|
|
repourl=stockholm_repo,
|
|
|
|
mode='full'
|
|
|
|
)
|
|
|
|
|
|
|
|
# prepare addShell function
|
|
|
|
def addShell(factory,**kwargs):
|
|
|
|
factory.addStep(steps.ShellCommand(**kwargs))
|
|
|
|
'';
|
|
|
|
builder = {
|
|
|
|
build-hosts = ''
|
|
|
|
f = util.BuildFactory()
|
|
|
|
f.addStep(grab_repo)
|
|
|
|
|
|
|
|
def build_host(user, host):
|
|
|
|
addShell(f,
|
|
|
|
name="{}".format(host),
|
|
|
|
env={
|
|
|
|
"NIX_PATH": "secrets=/var/src/stockholm/null:/var/src",
|
|
|
|
"NIX_REMOTE": "daemon",
|
|
|
|
"dummy_secrets": "true",
|
|
|
|
},
|
|
|
|
command=[
|
2017-07-28 11:37:39 +00:00
|
|
|
"nix-shell", "--run", " ".join(["test",
|
|
|
|
"--user={}".format(user),
|
|
|
|
"--system={}".format(host),
|
|
|
|
"--force-populate",
|
|
|
|
"--target=$LOGNAME@${config.krebs.build.host.name}$HOME/{}".format(user),
|
|
|
|
])
|
2017-07-31 10:25:53 +00:00
|
|
|
],
|
|
|
|
timeout=90001
|
2017-07-27 17:45:45 +00:00
|
|
|
)
|
|
|
|
|
2017-08-31 17:01:53 +00:00
|
|
|
${concatMapStringsSep "\n" (host:
|
|
|
|
"build_host(\"${host.owner.name}\", \"${host.name}\")"
|
|
|
|
) cfg.hosts}
|
2017-07-27 17:45:45 +00:00
|
|
|
|
|
|
|
bu.append(
|
|
|
|
util.BuilderConfig(
|
|
|
|
name="build-hosts",
|
|
|
|
slavenames=slavenames,
|
|
|
|
factory=f
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
enable = true;
|
|
|
|
web.enable = true;
|
|
|
|
irc = {
|
|
|
|
enable = true;
|
|
|
|
nick = "build|${hostname}";
|
2017-10-01 11:41:41 +00:00
|
|
|
server = "irc.r";
|
2017-10-01 12:26:12 +00:00
|
|
|
channels = [ "xxx" "noise" ];
|
2017-07-27 17:45:45 +00:00
|
|
|
allowForce = true;
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
c['buildbotURL'] = "http://build.${hostname}.r/"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
krebs.buildbot.slave = {
|
|
|
|
enable = true;
|
|
|
|
masterhost = "localhost";
|
|
|
|
username = "testslave";
|
|
|
|
password = "lasspass";
|
|
|
|
packages = with pkgs; [ gnumake jq nix populate ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|