From 4cabc9c286e5c74bb6f8ba73f4edf94918e35be5 Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Mon, 12 May 2025 13:08:59 +0200 Subject: [PATCH] gitlab-runner: write config as toml, don't clobber existing file The previous command would fail because of datetimes not being representable as JSON, wiping the config entirely because of the `sponge` invocation that doesn't care whether the program piped in fails. --- modules/services/gitlab-runner.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/services/gitlab-runner.nix b/modules/services/gitlab-runner.nix index 329fd72..11de998 100644 --- a/modules/services/gitlab-runner.nix +++ b/modules/services/gitlab-runner.nix @@ -19,6 +19,7 @@ let # make config file readable by service chown -R --reference=$HOME $(dirname ${configPath}) '' else '' + set -e export CONFIG_FILE=${configPath} mkdir -p $(dirname ${configPath}) @@ -92,8 +93,8 @@ let done # update global options - remarshal --if toml --of json ${configPath} \ - | jq -cM ${escapeShellArg (concatStringsSep " | " [ + tomlq -t \ + ${escapeShellArg (concatStringsSep " | " [ ".check_interval = ${toJSON cfg.checkInterval}" ".concurrent = ${toJSON cfg.concurrent}" ".sentry_dsn = ${toJSON cfg.sentryDSN}" @@ -103,9 +104,9 @@ let ".session_server.session_timeout = ${toJSON cfg.sessionServer.sessionTimeout}" "del(.[] | nulls)" "del(.session_server[] | nulls)" - ])} \ - | remarshal --if json --of toml \ - | sponge ${configPath} + ])} ${configPath} \ + > config.toml.new + mv config.toml.new ${configPath} # make config file readable by service chown -R --reference=$HOME $(dirname ${configPath}) @@ -559,7 +560,7 @@ in gawk jq moreutils - remarshal + yq # util-linux cfg.package coreutils