mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-11 17:50:08 +01:00
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:
parent
a076f0048a
commit
31f0e4ea13
2 changed files with 31 additions and 29 deletions
|
|
@ -2,7 +2,21 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
} @ args: let
|
} @ args: let
|
||||||
inherit (lib) types isAttrs filterAttrs mapAttrs mkOption mkOptionType isType literalExpression pipe;
|
inherit
|
||||||
|
(lib)
|
||||||
|
types
|
||||||
|
isAttrs
|
||||||
|
filterAttrs
|
||||||
|
mapAttrs
|
||||||
|
mkOption
|
||||||
|
mkOptionType
|
||||||
|
isType
|
||||||
|
literalExpression
|
||||||
|
pipe
|
||||||
|
hasInfix
|
||||||
|
concatMapAttrs
|
||||||
|
optionalAttrs
|
||||||
|
;
|
||||||
in rec {
|
in rec {
|
||||||
prepend = key: arr: job: {
|
prepend = key: arr: job: {
|
||||||
${key} = arr ++ (job.${key} or []);
|
${key} = arr ++ (job.${key} or []);
|
||||||
|
|
@ -33,10 +47,10 @@ in rec {
|
||||||
|
|
||||||
# filter job's variables to either only those containing store paths
|
# filter job's variables to either only those containing store paths
|
||||||
# or those that do not
|
# or those that do not
|
||||||
filterJobVariables = nix: job:
|
filterJobVariables = shouldContain: job:
|
||||||
lib.concatMapAttrs (
|
concatMapAttrs (
|
||||||
name: value:
|
name: value:
|
||||||
lib.optionalAttrs ((lib.hasInfix "/nix/store/" value) == nix) {
|
optionalAttrs ((hasInfix "/nix/store/" value) == shouldContain) {
|
||||||
${name} = value;
|
${name} = value;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,28 +16,16 @@ in
|
||||||
(prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job)
|
(prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job)
|
||||||
// (appendToAfterScript ["finalize_nix_ci"] job)
|
// (appendToAfterScript ["finalize_nix_ci"] job)
|
||||||
))
|
))
|
||||||
// optionalAttrs nixConfig.enable (
|
// optionalAttrs nixConfig.enable {
|
||||||
(let
|
|
||||||
variables =
|
variables =
|
||||||
(filterJobVariables false job)
|
(filterJobVariables false job)
|
||||||
// optionalAttrs nixConfig.enableRunnerCache {
|
// optionalAttrs nixConfig.enableRunnerCache {
|
||||||
NIX_CI_CACHE_STRATEGY = "runner";
|
NIX_CI_CACHE_STRATEGY = "runner";
|
||||||
};
|
};
|
||||||
in
|
|
||||||
# filter empty variables
|
|
||||||
optionalAttrs (variables != {}) {
|
|
||||||
inherit variables;
|
|
||||||
})
|
|
||||||
// (let
|
|
||||||
cache =
|
cache =
|
||||||
(toList (job.cache or []))
|
(toList (job.cache or []))
|
||||||
++ (optional nixConfig.enableRunnerCache {
|
++ (optional nixConfig.enableRunnerCache {
|
||||||
key = nixConfig.runnerCacheKey;
|
key = nixConfig.runnerCacheKey;
|
||||||
paths = [".nix-cache/"];
|
paths = [".nix-cache/"];
|
||||||
});
|
});
|
||||||
in
|
}
|
||||||
# filter empty cache
|
|
||||||
optionalAttrs (cache != []) {
|
|
||||||
inherit cache;
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue