mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-11 17:50:08 +01:00
49 lines
1.2 KiB
Nix
49 lines
1.2 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
cilib = import ./. {inherit lib pkgs;};
|
|
inherit (lib) toList;
|
|
inherit (cilib.helpers) prependToBeforeScript appendToAfterScript filterJobVariables;
|
|
in {
|
|
mkJobPatched = {
|
|
key,
|
|
job,
|
|
pipeline_name,
|
|
}:
|
|
builtins.removeAttrs (
|
|
(prependToBeforeScript [
|
|
"source setup_nix_ci \"gitlab-ci:pipeline:${pipeline_name}:job-deps:${key}\""
|
|
]
|
|
(appendToAfterScript [
|
|
"finalize_nix_ci"
|
|
]
|
|
job))
|
|
// lib.optionalAttrs job.nix.enable (
|
|
(let
|
|
variables =
|
|
(filterJobVariables false job)
|
|
// lib.optionalAttrs job.nix.enable-runner-cache {
|
|
NIX_CI_CACHE_STRATEGY = "runner";
|
|
};
|
|
in
|
|
# filter empty variables
|
|
lib.optionalAttrs (variables != {}) {
|
|
inherit variables;
|
|
})
|
|
// (let
|
|
cache =
|
|
(toList (job.cache or []))
|
|
++ (lib.optional (job.nix.enable-runner-cache) {
|
|
key = job.nix.runner-cache-key;
|
|
paths = [".nix-cache/"];
|
|
});
|
|
in
|
|
# filter empty cache
|
|
lib.optionalAttrs (cache != []) {
|
|
inherit cache;
|
|
})
|
|
)
|
|
) ["nix"];
|
|
}
|