fix(jobPatched): fix variables not being unset if all contain store paths

the goal was to remove "variables" when it's empty, but this resulted in
the original value being used if all of the variables contained store
paths. This is not supposed to happen and thus fixed with this.
This commit is contained in:
technofab 2025-09-03 15:17:51 +02:00
parent a076f0048a
commit 31f0e4ea13
No known key found for this signature in database
2 changed files with 31 additions and 29 deletions

View file

@ -16,28 +16,16 @@ in
(prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job)
// (appendToAfterScript ["finalize_nix_ci"] job)
))
// optionalAttrs nixConfig.enable (
(let
variables =
(filterJobVariables false job)
// optionalAttrs nixConfig.enableRunnerCache {
NIX_CI_CACHE_STRATEGY = "runner";
};
in
# filter empty variables
optionalAttrs (variables != {}) {
inherit variables;
})
// (let
cache =
(toList (job.cache or []))
++ (optional nixConfig.enableRunnerCache {
key = nixConfig.runnerCacheKey;
paths = [".nix-cache/"];
});
in
# filter empty cache
optionalAttrs (cache != []) {
inherit cache;
})
)
// optionalAttrs nixConfig.enable {
variables =
(filterJobVariables false job)
// optionalAttrs nixConfig.enableRunnerCache {
NIX_CI_CACHE_STRATEGY = "runner";
};
cache =
(toList (job.cache or []))
++ (optional nixConfig.enableRunnerCache {
key = nixConfig.runnerCacheKey;
paths = [".nix-cache/"];
});
}