diff --git a/lib/impl/jobPatched.nix b/lib/impl/jobPatched.nix index 4f2ddbd..73adb38 100644 --- a/lib/impl/jobPatched.nix +++ b/lib/impl/jobPatched.nix @@ -11,32 +11,28 @@ in pipelineName, nixConfig, }: - (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 ( - (let - variables = job.variables or {} // - 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; - }) - ) + 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) + // (let + variables = job.variables or {} // + 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; + }) diff --git a/tests/cilib_test.nix b/tests/cilib_test.nix index fea9dae..4fc9933 100644 --- a/tests/cilib_test.nix +++ b/tests/cilib_test.nix @@ -57,14 +57,14 @@ { name = "jobPatched nix disabled"; expected = { - /*cache = [{ + cache = [{ name = "some"; paths = [ "this" ]; }]; variables = { BASH = toString pkgs.bash; TEST = "work"; - };*/ + }; }; actual = mkJobPatched { key = "test"; @@ -206,14 +206,14 @@ before_script = [ "./init" ]; script = [ "echo Hello World!" ]; after_script = [ "./clean" ]; - /*cache = [{ + cache = [{ key = "simple"; paths = [ "~/random/" ]; }]; variables = { SAMPLE = "working"; HELLO = toString pkgs.hello; - };*/ + }; }; }; actual = (mkPipeline {