nix-gitlab-ci/lib/impl/jobPatched.nix
Skryta Istota d2f8a70675
fix(jobPatched) Removed too frequent filtering of variables
Removed excessive disposal of environment variables containing paths to nix store package files,
plus improved tests for this functionality.
2025-11-30 12:46:50 +01:00

42 lines
1.1 KiB
Nix

{
lib,
helpers,
}: let
inherit (lib) toList optionalAttrs optional;
inherit (helpers) prependToBeforeScript appendToAfterScript;
in
{
key,
job,
pipelineName,
nixConfig,
}:
(builtins.removeAttrs job ["variables" "cache"])
// (optionalAttrs nixConfig.enable (
(prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job)
// (appendToAfterScript ["finalize_nix_ci"] job)
))
// optionalAttrs nixConfig.enable (
(let
variables = job.variables or {} //
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;
})
)