Merge pull request #209716 from mpasternacki/mp/fix-gitlab-runner

Fix gitlab-runner NixOS module
This commit is contained in:
Matthieu Coudron 2023-01-08 18:00:39 +01:00 committed by GitHub
commit d1ab48e82b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,14 +9,14 @@ let
The hash is recorded in the runner's name because we can't do better yet
See https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29350 for more details
*/
genRunnerName = service: let
genRunnerName = name: service: let
hash = substring 0 12 (hashString "md5" (unsafeDiscardStringContext (toJSON service)));
in if service ? description
in if service ? description && service.description != null
then "${hash} ${service.description}"
else "${name}_${config.networking.hostName}_${hash}";
hashedServices = mapAttrs'
(name: service: nameValuePair (genRunnerName service) service) cfg.services;
(name: service: nameValuePair (genRunnerName name service) service) cfg.services;
configPath = ''"$HOME"/.gitlab-runner/config.toml'';
configureScript = pkgs.writeShellApplication {
name = "gitlab-runner-configure";
@ -38,7 +38,7 @@ let
'' else ''
export CONFIG_FILE=${configPath}
mkdir -p "$(dirname "${configPath}")"
mkdir -p "$(dirname ${configPath})"
touch ${configPath}
# update global options
@ -534,9 +534,9 @@ in {
};
};
config = mkIf cfg.enable {
warnings = (mapAttrsToList
warnings = mapAttrsToList
(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);
environment.systemPackages = [ cfg.package ];
systemd.services.gitlab-runner = {
@ -570,7 +570,7 @@ in {
ExecStartPre = "!${configureScript}/bin/gitlab-runner-configure";
ExecStart = "${startScript}/bin/gitlab-runner-start";
ExecReload = "!${configureScript}/bin/gitlab-runner-configure";
} // optionalAttrs (cfg.gracefulTermination) {
} // optionalAttrs cfg.gracefulTermination {
TimeoutStopSec = "${cfg.gracefulTimeout}";
KillSignal = "SIGQUIT";
KillMode = "process";