nixos/buildkite-agent: add "user" option
This allows buildkite-agent to run as another user. It'll still run builds from /var/lib/buildkite-agent and setup things in there.
This commit is contained in:
parent
5ed3474ca5
commit
8c6b1c3eaa
@ -29,6 +29,8 @@ let
|
|||||||
${concatStringsSep "\n" (mapAttrsToList mkHookEntry (filterAttrs (n: v: v != null) cfg.hooks))}
|
${concatStringsSep "\n" (mapAttrsToList mkHookEntry (filterAttrs (n: v: v != null) cfg.hooks))}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
defaultUser = "buildkite-agent";
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -56,6 +58,15 @@ in
|
|||||||
type = types.listOf types.package;
|
type = types.listOf types.package;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = defaultUser;
|
||||||
|
description = ''
|
||||||
|
Set this option when you want to run the buildkite agent as something else
|
||||||
|
than the default user "buildkite-agent".
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
tokenPath = mkOption {
|
tokenPath = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
description = ''
|
description = ''
|
||||||
@ -185,8 +196,8 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf config.services.buildkite-agent.enable {
|
config = mkIf config.services.buildkite-agent.enable {
|
||||||
users.users.buildkite-agent =
|
users.users.buildkite-agent = mkIf (cfg.user == defaultUser) {
|
||||||
{ name = "buildkite-agent";
|
name = "buildkite-agent";
|
||||||
home = cfg.dataDir;
|
home = cfg.dataDir;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
description = "Buildkite agent user";
|
description = "Buildkite agent user";
|
||||||
@ -230,7 +241,7 @@ in
|
|||||||
|
|
||||||
serviceConfig =
|
serviceConfig =
|
||||||
{ ExecStart = "${cfg.package}/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";
|
User = cfg.user;
|
||||||
RestartSec = 5;
|
RestartSec = 5;
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
TimeoutSec = 10;
|
TimeoutSec = 10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user