diff --git a/lib/types.nix b/lib/types.nix index 4d6ac51c8988..46030dea7263 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -349,6 +349,16 @@ rec { functor = (defaultFunctor name) // { wrapped = elemType; }; }; + functionTo = elemType: mkOptionType { + name = "function that evaluates to a(n) ${elemType.name}"; + check = isFunction; + merge = loc: defs: + fnArgs: elemType.merge loc (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs); + getSubOptions = elemType.getSubOptions; + getSubModules = elemType.getSubModules; + substSubModules = m: functionTo (elemType.substSubModules m); + }; + # A submodule (like typed attribute set). See NixOS manual. submodule = opts: let