Skip to content

Commit

Permalink
services/buildkite-agent: update service for buildkite 3
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickvP authored and kirelagin committed Apr 23, 2019
1 parent 8d68223 commit 3a7b1d3
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ in
'';
};

extraSetup = mkOption {
type = types.lines;
default = "";
example = "touch /var/lib/buildkite-agent/test";
description = ''
Extra commands to execute (as root) while setting up the buildkite dir and config.
The directory ownership will be fixed up afterwards.
'';
};

openssh =
{ privateKeyPath = mkOption {
type = types.path;
Expand Down Expand Up @@ -181,6 +191,14 @@ in
instead.
'';
};

shell = mkOption {
type = types.string;
default = "${pkgs.bash}/bin/bash -e -c";
description = ''
Command that buildkite-agent 3 will execute when it spawns a shell.
'';
};
};
};

Expand All @@ -203,10 +221,12 @@ in
environment = config.networking.proxy.envVars // {
HOME = cfg.dataDir;
NIX_REMOTE = "daemon";
BUILDKITE_SHELL = cfg.shell;
};

## NB: maximum care is taken so that secrets (ssh keys and the CI token)
## don't end up in the Nix store.
## This preStart script runs as root
preStart = let
sshDir = "${cfg.dataDir}/.ssh";
in
Expand All @@ -224,14 +244,21 @@ in
hooks-path="${cfg.hooksPath}"
${cfg.extraConfig}
EOF
${cfg.extraSetup}
chown -R buildkite-agent ${cfg.dataDir}
'';

serviceConfig =
{ ExecStart = "${pkgs.buildkite-agent}/bin/buildkite-agent start --config /var/lib/buildkite-agent/buildkite-agent.cfg";
{ ExecStart = "${cfg.package}/bin/buildkite-agent start --config /var/lib/buildkite-agent/buildkite-agent.cfg";
User = "buildkite-agent";
RestartSec = 5;
Restart = "on-failure";
TimeoutSec = 10;
# set a long timeout to give buildkite-agent a chance to finish current builds
TimeoutStopSec = "2 min";
KillMode = "mixed";
# run the preStart script as root
PermissionsStartOnly = true;
};
};

Expand Down

0 comments on commit 3a7b1d3

Please sign in to comment.