From ce6d4070a616554c0ca6948338b47cb192f7306a Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 19 Dec 2012 22:49:21 -0500 Subject: [PATCH] Add a 'functionTo x' type. This is mainly to for the 'merge' concept, but I made a guess as to what iter and fold would mean for functions. --- pkgs/lib/types.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 {