* Add a function to replace "pkgs.checker". The function checkModule does a

traversal of all definitions and also check definitions contained inside
  sub-modules.

svn path=/nixpkgs/trunk/; revision=18241
This commit is contained in:
Nicolas Pierron 2009-11-07 01:59:50 +00:00
parent 233d72e4fb
commit 88f113d032

View file

@ -238,6 +238,7 @@ rec {
result =
if isOption then value
else if !hasOptions then {}
else if all isAttrs values then recurse
else
throw "${eol
@ -323,4 +324,28 @@ rec {
)
);
# Visit all definitions to raise errors related to undeclared options.
checkModule = path: {config, options, ...}@m:
let
eol = "\n";
addName = name:
if path == "" then name else path + "." + name;
in
if lib.isOption options then
if options ? options then
options.type.fold
(cfg: res: res && checkModule (options.type.docPath path) cfg._args)
true config
else
true
else if isAttrs options && lib.attrNames m.options != [] then
all (name:
lib.addErrorContext "${eol
}while checking the attribute '${addName name}'.${eol
}" (checkModule (addName name) (selectModule name m))
) (lib.attrNames m.config)
else
builtins.trace "try to evaluate config ${lib.showVal config}."
false;
}