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,
|
||||
nixConfig,
|
||||
}:
|
||||
job
|
||||
(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 {
|
||||
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/"];
|
||||
});
|
||||
}
|
||||
// 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;
|
||||
})
|
||||
)
|
||||
|
|
|
|||
|
|
@ -148,10 +148,7 @@
|
|||
name = "handle store paths in variables";
|
||||
expected = {
|
||||
stages = ["test"];
|
||||
test = {
|
||||
stage = "test";
|
||||
variables."TEST" = "${pkgs.hello}";
|
||||
};
|
||||
test.stage = "test";
|
||||
};
|
||||
actual =
|
||||
(mkPipeline {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue