diff --git a/lib/impl/helpers.nix b/lib/impl/helpers.nix index 66a42cf..4b08c7f 100644 --- a/lib/impl/helpers.nix +++ b/lib/impl/helpers.nix @@ -2,7 +2,21 @@ pkgs, lib, } @ args: let - inherit (lib) types isAttrs filterAttrs mapAttrs mkOption mkOptionType isType literalExpression pipe; + inherit + (lib) + types + isAttrs + filterAttrs + mapAttrs + mkOption + mkOptionType + isType + literalExpression + pipe + hasInfix + concatMapAttrs + optionalAttrs + ; in rec { prepend = key: arr: job: { ${key} = arr ++ (job.${key} or []); @@ -33,10 +47,10 @@ in rec { # filter job's variables to either only those containing store paths # or those that do not - filterJobVariables = nix: job: - lib.concatMapAttrs ( + filterJobVariables = shouldContain: job: + concatMapAttrs ( name: value: - lib.optionalAttrs ((lib.hasInfix "/nix/store/" value) == nix) { + optionalAttrs ((hasInfix "/nix/store/" value) == shouldContain) { ${name} = value; } ) diff --git a/lib/impl/jobPatched.nix b/lib/impl/jobPatched.nix index 4bf0e00..9997caa 100644 --- a/lib/impl/jobPatched.nix +++ b/lib/impl/jobPatched.nix @@ -16,28 +16,16 @@ in (prependToBeforeScript ["source setup_nix_ci \"gitlab-ci:pipeline:${pipelineName}:job-deps:${key}\""] job) // (appendToAfterScript ["finalize_nix_ci"] job) )) - // 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; - }) - ) + // 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/"]; + }); + }