diff --git a/pkgs/lib/types.nix b/pkgs/lib/types.nix index 38ae7b43630..b99fe5a5771 100644 --- a/pkgs/lib/types.nix +++ b/pkgs/lib/types.nix @@ -176,6 +176,19 @@ rec { fold = op: nul: v: if v == null then nul else elemType.fold op nul v; }; + functionTo = elemType: mkOptionType { + name = "function that evaluates to a(n) ${elemType.name}"; + check = lib.traceValIfNot builtins.isFunction; + merge = fns: + args: elemType.merge (map (fn: fn args) fns) + # These are guesses, I don't fully understand iter, fold, delayOnGlobalEval + iter = f: path: v: + args: elemType.iter f path (v args); + fold = op: nul: v: + args: elemType.fold op nul (v args); + inherit (elemType) hasOptions delayOnGlobalEval; + }; + # !!! this should be a type constructor that takes the options as # an argument. optionSet = mkOptionType {