mirror of
https://gitlab.com/TECHNOFAB/nix-gitlab-ci.git
synced 2025-12-12 02:00:13 +01:00
feat: add support for nix store paths in variables
by exporting them at runtime and removing them from the pipeline definition itself closes #3
This commit is contained in:
parent
ed80957884
commit
e3b35ec8ae
2 changed files with 28 additions and 1 deletions
|
|
@ -42,9 +42,14 @@
|
|||
when = "delayed";
|
||||
start_in = "1 hour";
|
||||
deps = [pkgs.hello pkgs.curl];
|
||||
variables = {
|
||||
TEST = "test";
|
||||
TEST_WITH_DERIVATION = "${pkgs.hello}/test";
|
||||
};
|
||||
script = [
|
||||
"hello"
|
||||
"curl google.de"
|
||||
"echo $TEST $TEST_WITH_DERIVATION"
|
||||
];
|
||||
};
|
||||
"test-non-nix" = {
|
||||
|
|
|
|||
|
|
@ -138,10 +138,25 @@
|
|||
# before, we just allowed pkgs inside the script string directly, but now with the ability to source this file
|
||||
# we can support different architectures between runners (eg. the arch of the initial runner does not matter)
|
||||
jobsMappedForDeps =
|
||||
mapAttrs (key: job: {
|
||||
mapAttrs (key: job: let
|
||||
variablesWithStorePaths =
|
||||
lib.concatMapAttrs (
|
||||
name: value:
|
||||
if lib.hasInfix "/nix/store/" value
|
||||
then {
|
||||
${name} = value;
|
||||
}
|
||||
else {}
|
||||
)
|
||||
(job.variables or {});
|
||||
variableExports = lib.concatMapStrings (x: "${x}\n") (
|
||||
lib.mapAttrsToList (name: value: "export ${name}=\"${value}\"") variablesWithStorePaths
|
||||
);
|
||||
in {
|
||||
name = "gitlab-ci-job-deps:${key}";
|
||||
value = pkgs.writeShellScript "gitlab-ci-job-deps:${key}" ''
|
||||
export PATH="${lib.makeBinPath job.deps}:$PATH";
|
||||
${variableExports}
|
||||
'';
|
||||
})
|
||||
jobs;
|
||||
|
|
@ -166,6 +181,13 @@
|
|||
job))
|
||||
// lib.optionalAttrs job.nix {
|
||||
image = job.image;
|
||||
variables = lib.concatMapAttrs (name: value:
|
||||
if lib.hasInfix "/nix/store/" value
|
||||
then {}
|
||||
else {
|
||||
${name} = value;
|
||||
})
|
||||
(job.variables or {});
|
||||
}
|
||||
) ["nix" "deps"];
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue