{lib, ...} @ args: let inherit (lib) isAttrs filterAttrs mapAttrs; in rec { prepend = key: arr: job: job // lib.optionalAttrs (job.nix.enable or false) { ${key} = arr ++ (job.${key} or []); }; append = key: arr: job: job // lib.optionalAttrs (job.nix.enable or false) { ${key} = (job.${key} or []) ++ arr; }; prependToBeforeScript = prepend "before_script"; appendToAfterScript = append "after_script"; # json is also valid yaml and this removes dependency on jq and/or remarshal # (used in pkgs.formats.json and pkgs.formats.yaml respectively) toYaml = name: value: builtins.toFile name (builtins.toJSON value); customMapAttrs = cb: set: builtins.listToAttrs (builtins.map (key: cb key (builtins.getAttr key set)) (builtins.attrNames set)); filterAttrsRec = pred: v: if isAttrs v then filterAttrs pred (mapAttrs (path: filterAttrsRec pred) v) else v; # filter job's variables to either only those containing store paths # or those that do not filterJobVariables = nix: job: lib.concatMapAttrs ( name: value: lib.optionalAttrs ((lib.hasInfix "/nix/store/" value) == nix) { ${name} = value; } ) (job.variables or {}); # args.pkgs so "pkgs" does not need to be passed all the time stdenvMinimal = args.pkgs.stdenvNoCC.override { cc = null; preHook = ""; allowedRequisites = null; initialPath = with args.pkgs; [coreutils findutils]; extraNativeBuildInputs = []; }; }