* Do not always use the current result as argument.

* "filterOptionSets" returns the only option per attribute instead of a list of options.

svn path=/nixpkgs/trunk/; revision=12520
This commit is contained in:
Nicolas Pierron 2008-08-06 18:34:11 +00:00
parent 7061a01749
commit 0ce4cafd88

View File

@ -399,25 +399,27 @@ rec {
name = if path == "" then attr else path + "." + attr;
test = partition isOption opts;
in
if test.right == []
then filterOptionSets name test.wrong
else map (x: x // { inherit name; }) test.right
if test.right == [] then filterOptionSets name test.wrong
else if tail test.right != [] then throw "Multiple options for '${name}'."
else { inherit name; } // (head test.right)
) opts
else {};
# Evaluate a list of option sets that would be merged with the
# function "merge" which expects two arguments. The attribute named
# "require" is used to imports option declarations and bindings.
finalReferenceOptionSets = merge: pkgs: opts:
finalOptionSetsFun = merge: pkgs: opts:
let optionSet = final: configFun:
if __isFunction configFun then configFun pkgs final
else configFun; # backward compatibility.
in
finalReference (final: merge ""
final: merge ""
(map (x: removeAttrs x ["require"])
(uniqFlattenAttr (optionSet final) "require" [] (toList opts))
)
);
);
finalReferenceOptionSets = merge: pkgs: opts:
finalReference (finalOptionSetsFun merge pkgs opts);
optionAttrSetToDocList = (l: attrs:
(if (getAttr ["_type"] "" attrs) == "option" then