nixos/gitlab-runner: add settings option
This commit is contained in:
parent
c8c8b2593f
commit
b4028126f1
@ -22,6 +22,14 @@ let
|
|||||||
export CONFIG_FILE=${configPath}
|
export CONFIG_FILE=${configPath}
|
||||||
|
|
||||||
mkdir -p $(dirname ${configPath})
|
mkdir -p $(dirname ${configPath})
|
||||||
|
touch ${configPath}
|
||||||
|
|
||||||
|
# update global options
|
||||||
|
remarshal --if toml --of json ${configPath} \
|
||||||
|
| jq -cM 'with_entries(select([.key] | inside(["runners"])))' \
|
||||||
|
| jq -scM '.[0] + .[1]' - <(echo ${escapeShellArg (toJSON cfg.settings)}) \
|
||||||
|
| remarshal --if json --of toml \
|
||||||
|
| sponge ${configPath}
|
||||||
|
|
||||||
# remove no longer existing services
|
# remove no longer existing services
|
||||||
gitlab-runner verify --delete
|
gitlab-runner verify --delete
|
||||||
@ -91,22 +99,6 @@ let
|
|||||||
--name "$NAME" && sleep 1
|
--name "$NAME" && sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# update global options
|
|
||||||
remarshal --if toml --of json ${configPath} \
|
|
||||||
| jq -cM ${escapeShellArg (concatStringsSep " | " [
|
|
||||||
".check_interval = ${toJSON cfg.checkInterval}"
|
|
||||||
".concurrent = ${toJSON cfg.concurrent}"
|
|
||||||
".sentry_dsn = ${toJSON cfg.sentryDSN}"
|
|
||||||
".listen_address = ${toJSON cfg.prometheusListenAddress}"
|
|
||||||
".session_server.listen_address = ${toJSON cfg.sessionServer.listenAddress}"
|
|
||||||
".session_server.advertise_address = ${toJSON cfg.sessionServer.advertiseAddress}"
|
|
||||||
".session_server.session_timeout = ${toJSON cfg.sessionServer.sessionTimeout}"
|
|
||||||
"del(.[] | nulls)"
|
|
||||||
"del(.session_server[] | nulls)"
|
|
||||||
])} \
|
|
||||||
| remarshal --if json --of toml \
|
|
||||||
| sponge ${configPath}
|
|
||||||
|
|
||||||
# make config file readable by service
|
# make config file readable by service
|
||||||
chown -R --reference=$HOME $(dirname ${configPath})
|
chown -R --reference=$HOME $(dirname ${configPath})
|
||||||
'');
|
'');
|
||||||
@ -133,85 +125,15 @@ in
|
|||||||
for settings not covered by this module.
|
for settings not covered by this module.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
checkInterval = mkOption {
|
settings = mkOption {
|
||||||
type = types.int;
|
|
||||||
default = 0;
|
|
||||||
example = literalExpression "with lib; (length (attrNames config.services.gitlab-runner.services)) * 3";
|
|
||||||
description = ''
|
|
||||||
Defines the interval length, in seconds, between new jobs check.
|
|
||||||
The default value is 3;
|
|
||||||
if set to 0 or lower, the default value will be used.
|
|
||||||
See <link xlink:href="https://docs.gitlab.com/runner/configuration/advanced-configuration.html#how-check_interval-works">runner documentation</link> for more information.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
concurrent = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 1;
|
|
||||||
example = literalExpression "config.nix.settings.max-jobs";
|
|
||||||
description = ''
|
|
||||||
Limits how many jobs globally can be run concurrently.
|
|
||||||
The most upper limit of jobs using all defined runners.
|
|
||||||
0 does not mean unlimited.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
sentryDSN = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = null;
|
|
||||||
example = "https://public:private@host:port/1";
|
|
||||||
description = ''
|
|
||||||
Data Source Name for tracking of all system level errors to Sentry.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
prometheusListenAddress = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = null;
|
|
||||||
example = "localhost:8080";
|
|
||||||
description = ''
|
|
||||||
Address (<host>:<port>) on which the Prometheus metrics HTTP server
|
|
||||||
should be listening.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
sessionServer = mkOption {
|
|
||||||
type = types.submodule {
|
type = types.submodule {
|
||||||
options = {
|
freeformType = (pkgs.formats.json { }).type;
|
||||||
listenAddress = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = null;
|
|
||||||
example = "0.0.0.0:8093";
|
|
||||||
description = ''
|
|
||||||
An internal URL to be used for the session server.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
advertiseAddress = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
default = null;
|
|
||||||
example = "runner-host-name.tld:8093";
|
|
||||||
description = ''
|
|
||||||
The URL that the Runner will expose to GitLab to be used
|
|
||||||
to access the session server.
|
|
||||||
Fallbacks to <option>listenAddress</option> if not defined.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
sessionTimeout = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 1800;
|
|
||||||
description = ''
|
|
||||||
How long in seconds the session can stay active after
|
|
||||||
the job completes (which will block the job from finishing).
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
default = { };
|
default = { };
|
||||||
example = literalExpression ''
|
|
||||||
{
|
|
||||||
listenAddress = "0.0.0.0:8093";
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
description = ''
|
description = ''
|
||||||
The session server allows the user to interact with jobs
|
Global gitlab-runner configuration. See
|
||||||
that the Runner is responsible for. A good example of this is the
|
<link xlink:href="https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-global-section"/>
|
||||||
<link xlink:href="https://docs.gitlab.com/ee/ci/interactive_web_terminal/index.html">interactive web terminal</link>.
|
for supported values.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
gracefulTermination = mkOption {
|
gracefulTermination = mkOption {
|
||||||
@ -537,6 +459,7 @@ in
|
|||||||
(n: v: "services.gitlab-runner.services.${n}.`registrationConfigFile` points to a file in Nix Store. You should use quoted absolute path to prevent this.")
|
(n: v: "services.gitlab-runner.services.${n}.`registrationConfigFile` points to a file in Nix Store. You should use quoted absolute path to prevent this.")
|
||||||
(filterAttrs (n: v: isStorePath v.registrationConfigFile) cfg.services))
|
(filterAttrs (n: v: isStorePath v.registrationConfigFile) cfg.services))
|
||||||
++ optional (cfg.configFile != null) "services.gitlab-runner.`configFile` is deprecated, please use services.gitlab-runner.`services`.";
|
++ optional (cfg.configFile != null) "services.gitlab-runner.`configFile` is deprecated, please use services.gitlab-runner.`services`.";
|
||||||
|
|
||||||
environment.systemPackages = [ cfg.package ];
|
environment.systemPackages = [ cfg.package ];
|
||||||
systemd.services.gitlab-runner = {
|
systemd.services.gitlab-runner = {
|
||||||
description = "Gitlab Runner";
|
description = "Gitlab Runner";
|
||||||
@ -584,5 +507,14 @@ in
|
|||||||
(mkRenamedOptionModule [ "services" "gitlab-runner" "packages" ] [ "services" "gitlab-runner" "extraPackages" ] )
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "packages" ] [ "services" "gitlab-runner" "extraPackages" ] )
|
||||||
(mkRemovedOptionModule [ "services" "gitlab-runner" "configOptions" ] "Use services.gitlab-runner.services option instead" )
|
(mkRemovedOptionModule [ "services" "gitlab-runner" "configOptions" ] "Use services.gitlab-runner.services option instead" )
|
||||||
(mkRemovedOptionModule [ "services" "gitlab-runner" "workDir" ] "You should move contents of workDir (if any) to /var/lib/gitlab-runner" )
|
(mkRemovedOptionModule [ "services" "gitlab-runner" "workDir" ] "You should move contents of workDir (if any) to /var/lib/gitlab-runner" )
|
||||||
|
|
||||||
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "checkInterval" ] [ "services" "gitlab-runner" "settings" "check_interval" ] )
|
||||||
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "concurrent" ] [ "services" "gitlab-runner" "settings" "concurrent" ] )
|
||||||
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "sentryDSN" ] [ "services" "gitlab-runner" "settings" "sentry_dsn" ] )
|
||||||
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "prometheusListenAddress" ] [ "services" "gitlab-runner" "settings" "listen_address" ] )
|
||||||
|
|
||||||
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "sessionServer" "listenAddress" ] [ "services" "gitlab-runner" "settings" "session_server" "listen_address" ] )
|
||||||
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "sessionServer" "advertiseAddress" ] [ "services" "gitlab-runner" "settings" "session_server" "advertise_address" ] )
|
||||||
|
(mkRenamedOptionModule [ "services" "gitlab-runner" "sessionServer" "sessionTimeout" ] [ "services" "gitlab-runner" "settings" "session_server" "session_timeout" ] )
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user