Handle apply attribute for each option declared with MkOption.
This is similar to the new-proposal in upstart-jobs except that the default value is also processed with this function. (the existing merge function acts only on extra values). svn path=/nixpkgs/trunk/; revision=13308
This commit is contained in:
parent
ed57af85a7
commit
08b583682a
@ -407,13 +407,13 @@ rec {
|
|||||||
zip (attr: opts:
|
zip (attr: opts:
|
||||||
let
|
let
|
||||||
name = if path == "" then attr else path + "." + attr;
|
name = if path == "" then attr else path + "." + attr;
|
||||||
defaultOpt = { merge = mergeDefaultOption; };
|
|
||||||
test = partition isOption opts;
|
test = partition isOption opts;
|
||||||
|
opt = ({ merge = mergeDefaultOption; apply = id; } // head test.right);
|
||||||
in
|
in
|
||||||
if test.right == [] then mergeOptionSets noOption name test.wrong
|
if test.right == [] then mergeOptionSets noOption name test.wrong
|
||||||
else if tail test.right != [] then throw "Multiple options for '${name}'."
|
else if tail test.right != [] then throw "Multiple options for '${name}'."
|
||||||
else if test.wrong == [] then (head test.right).default
|
else if test.wrong == [] then opt.apply opt.default
|
||||||
else (defaultOpt // head test.right).merge name test.wrong
|
else opt.apply (opt.merge name test.wrong)
|
||||||
) opts
|
) opts
|
||||||
else noOption path opts;
|
else noOption path opts;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user