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:
|
||||
let
|
||||
name = if path == "" then attr else path + "." + attr;
|
||||
defaultOpt = { merge = mergeDefaultOption; };
|
||||
test = partition isOption opts;
|
||||
opt = ({ merge = mergeDefaultOption; apply = id; } // head test.right);
|
||||
in
|
||||
if test.right == [] then mergeOptionSets noOption name test.wrong
|
||||
else if tail test.right != [] then throw "Multiple options for '${name}'."
|
||||
else if test.wrong == [] then (head test.right).default
|
||||
else (defaultOpt // head test.right).merge name test.wrong
|
||||
else if test.wrong == [] then opt.apply opt.default
|
||||
else opt.apply (opt.merge name test.wrong)
|
||||
) opts
|
||||
else noOption path opts;
|
||||
|
||||
|
|
Loading…
Reference in New Issue