mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
nixos/gitlab-runner: add more global options (#86946)
This commit is contained in:
parent
6e46544464
commit
fc9f994ee5
1 changed files with 77 additions and 6 deletions
|
@ -1,14 +1,16 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
with builtins;
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.services.gitlab-runner;
|
cfg = config.services.gitlab-runner;
|
||||||
hasDocker = config.virtualisation.docker.enable;
|
hasDocker = config.virtualisation.docker.enable;
|
||||||
hashedServices = with builtins; (mapAttrs' (name: service: nameValuePair
|
hashedServices = mapAttrs'
|
||||||
"${name}_${config.networking.hostName}_${
|
(name: service: nameValuePair
|
||||||
|
"${name}_${config.networking.hostName}_${
|
||||||
substring 0 12
|
substring 0 12
|
||||||
(hashString "md5" (unsafeDiscardStringContext (toJSON service)))}"
|
(hashString "md5" (unsafeDiscardStringContext (toJSON service)))}"
|
||||||
service)
|
service)
|
||||||
cfg.services);
|
cfg.services;
|
||||||
configPath = "$HOME/.gitlab-runner/config.toml";
|
configPath = "$HOME/.gitlab-runner/config.toml";
|
||||||
configureScript = pkgs.writeShellScriptBin "gitlab-runner-configure" (
|
configureScript = pkgs.writeShellScriptBin "gitlab-runner-configure" (
|
||||||
if (cfg.configFile != null) then ''
|
if (cfg.configFile != null) then ''
|
||||||
|
@ -76,7 +78,7 @@ let
|
||||||
++ map (v: "--docker-allowed-images ${escapeShellArg v}") service.dockerAllowedImages
|
++ map (v: "--docker-allowed-images ${escapeShellArg v}") service.dockerAllowedImages
|
||||||
++ map (v: "--docker-allowed-services ${escapeShellArg v}") service.dockerAllowedServices
|
++ map (v: "--docker-allowed-services ${escapeShellArg v}") service.dockerAllowedServices
|
||||||
)
|
)
|
||||||
))} && sleep 1
|
))} && sleep 1 || exit 1
|
||||||
fi
|
fi
|
||||||
'') hashedServices)}
|
'') hashedServices)}
|
||||||
|
|
||||||
|
@ -89,8 +91,17 @@ let
|
||||||
|
|
||||||
# update global options
|
# update global options
|
||||||
remarshal --if toml --of json ${configPath} \
|
remarshal --if toml --of json ${configPath} \
|
||||||
| jq -cM '.check_interval = ${toString cfg.checkInterval} |
|
| jq -cM ${escapeShellArg (concatStringsSep " | " [
|
||||||
.concurrent = ${toString cfg.concurrent}' \
|
".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 \
|
| remarshal --if json --of toml \
|
||||||
| sponge ${configPath}
|
| sponge ${configPath}
|
||||||
|
|
||||||
|
@ -141,6 +152,66 @@ in
|
||||||
0 does not mean unlimited.
|
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 {
|
||||||
|
options = {
|
||||||
|
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 = { };
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
listenAddress = "0.0.0.0:8093";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
The session server allows the user to interact with jobs
|
||||||
|
that the Runner is responsible for. A good example of this is the
|
||||||
|
<link xlink:href="https://docs.gitlab.com/ee/ci/interactive_web_terminal/index.html">interactive web terminal</link>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
gracefulTermination = mkOption {
|
gracefulTermination = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue