mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-11 17:50:08 +01:00
chore: better solution for handling store paths in variables
This commit is contained in:
parent
31f0e4ea13
commit
5e2ae29660
2 changed files with 27 additions and 18 deletions
|
|
@ -11,21 +11,33 @@ in
|
||||||
pipelineName,
|
pipelineName,
|
||||||
nixConfig,
|
nixConfig,
|
||||||
}:
|
}:
|
||||||
job
|
(builtins.removeAttrs job ["variables" "cache"])
|
||||||
// (optionalAttrs nixConfig.enable (
|
// (optionalAttrs nixConfig.enable (
|
||||||
(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 (
|
||||||
variables =
|
(let
|
||||||
(filterJobVariables false job)
|
variables =
|
||||||
// optionalAttrs nixConfig.enableRunnerCache {
|
(filterJobVariables false job)
|
||||||
NIX_CI_CACHE_STRATEGY = "runner";
|
// optionalAttrs nixConfig.enableRunnerCache {
|
||||||
};
|
NIX_CI_CACHE_STRATEGY = "runner";
|
||||||
cache =
|
};
|
||||||
(toList (job.cache or []))
|
in
|
||||||
++ (optional nixConfig.enableRunnerCache {
|
# filter empty variables
|
||||||
key = nixConfig.runnerCacheKey;
|
optionalAttrs (variables != {}) {
|
||||||
paths = [".nix-cache/"];
|
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;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,7 @@
|
||||||
name = "handle store paths in variables";
|
name = "handle store paths in variables";
|
||||||
expected = {
|
expected = {
|
||||||
stages = ["test"];
|
stages = ["test"];
|
||||||
test = {
|
test.stage = "test";
|
||||||
stage = "test";
|
|
||||||
variables."TEST" = "${pkgs.hello}";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
actual =
|
actual =
|
||||||
(mkPipeline {
|
(mkPipeline {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue