diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-09-19 16:49:31 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-09-19 16:49:31 +0000 |
commit | 5f138aebde2269eeee123dcc0a789dbee792281a (patch) | |
tree | db547d7404ea728e0c9998217cb33e88e1c41d3e /pkgs/lib | |
parent | bf4162eb0b3435c09ade5dc4dada99431e5b13df (diff) | |
download | nixlib-5f138aebde2269eeee123dcc0a789dbee792281a.tar nixlib-5f138aebde2269eeee123dcc0a789dbee792281a.tar.gz nixlib-5f138aebde2269eeee123dcc0a789dbee792281a.tar.bz2 nixlib-5f138aebde2269eeee123dcc0a789dbee792281a.tar.lz nixlib-5f138aebde2269eeee123dcc0a789dbee792281a.tar.xz nixlib-5f138aebde2269eeee123dcc0a789dbee792281a.tar.zst nixlib-5f138aebde2269eeee123dcc0a789dbee792281a.zip |
Fix: Use the check function defined in the option declaration if it exists.
svn path=/nixpkgs/trunk/; revision=17277
Diffstat (limited to 'pkgs/lib')
-rw-r--r-- | pkgs/lib/options.nix | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/pkgs/lib/options.nix b/pkgs/lib/options.nix index 06d4fad8a325..b9ed6e2ec6c6 100644 --- a/pkgs/lib/options.nix +++ b/pkgs/lib/options.nix @@ -46,19 +46,21 @@ rec { apply = lib.id; }; - mergeFromType = opt: + functionsFromType = opt: if decl ? type && decl.type ? merge then - opt // { merge = decl.type.merge; } + opt + // optionalAttrs (decl.type ? merge) { inherit (decl.type) merge; } + // optionalAttrs (decl.type ? check) { inherit (decl.type) check; } else opt; addDeclaration = opt: opt // decl; ensureMergeInputType = opt: - if decl ? type then + if opt ? check then opt // { merge = list: - if all decl.type.check list then + if all opt.check list then opt.merge list else throw "One of the definitions has a bad type."; @@ -66,18 +68,18 @@ rec { else opt; ensureDefaultType = opt: - if decl ? type && decl ? default then + if opt ? check && opt ? default then opt // { default = - if decl.type.check decl.default then - decl.default + if opt.check opt.default then + opt.default else throw "The default value has a bad type."; } else opt; handleOptionSets = opt: - if decl ? type && decl.type.hasOptions then + if opt ? type && opt.type.hasOptions then let optionConfig = opts: config: @@ -86,7 +88,7 @@ rec { in opt // { merge = list: - decl.type.iter + opt.type.iter (path: opts: (lib.fix (fixableMergeFun (recurseInto path) (optionConfig opts)) @@ -95,7 +97,7 @@ rec { opt.name (opt.merge list); options = - let path = decl.type.docPath opt.name; in + let path = opt.type.docPath opt.name; in (lib.fix (fixableMergeFun (recurseInto path) (optionConfig [])) ).options; @@ -105,7 +107,7 @@ rec { in foldl (opt: f: f opt) init [ # default settings - mergeFromType + functionsFromType # user settings addDeclaration |