diff --git a/lib/impl/jobPatched.nix b/lib/impl/jobPatched.nix index c7134fb..367a374 100644 --- a/lib/impl/jobPatched.nix +++ b/lib/impl/jobPatched.nix @@ -11,13 +11,13 @@ in pipelineName, nixConfig, }: - (builtins.removeAttrs job ["variables" "cache"]) - // (optionalAttrs nixConfig.enable ( - (prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job) + if ! nixConfig.enable + then job + else + (builtins.removeAttrs job ["variables" "cache"]) + // (prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job) // (appendToAfterScript ["finalize_nix_ci"] job) - )) - // optionalAttrs nixConfig.enable ( - (let + // (let variables = (filterJobVariables false job) // optionalAttrs nixConfig.enableRunnerCache { @@ -40,4 +40,3 @@ in optionalAttrs (cache != []) { inherit cache; }) - ) diff --git a/tests/cilib_test.nix b/tests/cilib_test.nix index 2322906..3b76fb8 100644 --- a/tests/cilib_test.nix +++ b/tests/cilib_test.nix @@ -64,6 +64,22 @@ nixConfig.enable = false; }; } + { + name = "jobPatched nix disabled with variables and cache"; + expected = { + variables."HELLO" = "world"; + cache = [{key = "example";}]; + }; + actual = mkJobPatched { + key = "test"; + pipelineName = "test"; + job = { + variables."HELLO" = "world"; + cache = [{key = "example";}]; + }; + nixConfig.enable = false; + }; + } { name = "jobPatched without runner cache"; expected = { @@ -145,10 +161,13 @@ ''; } { - name = "handle store paths in variables"; + name = "ignore store paths in variables with nix disabled"; expected = { stages = ["test"]; - test.stage = "test"; + test = { + stage = "test"; + variables."TEST" = "${pkgs.hello}"; + }; }; actual = (mkPipeline {