modules (moduleClosure): use imap instead of map to produce uniq keys for

the genericClosure.

svn path=/nixpkgs/trunk/; revision=27014
This commit is contained in:
Nicolas Pierron 2011-04-27 18:41:37 +00:00
parent 85d3fd3e3c
commit 02677481ae

View file

@ -80,19 +80,29 @@ rec {
moduleClosure = initModules: args:
let
moduleImport = m:
moduleImport = origin: index: m:
let m' = applyIfFunction (importIfPath m) args;
in (unifyModuleSyntax m') // {
# used by generic closure to avoid duplicated imports.
key = if isPath m then m else if m' ? key then m'.key else "<unknown location>";
key =
if isPath m then m
else if m' ? key then m'.key
else newModuleName origin index;
};
getImports = m: attrByPath ["imports"] [] m;
newModuleName = origin: index:
"${origin.key}:<import-${toString index}>";
topLevel = {
key = "<top-level>";
};
in
(lazyGenericClosure {
startSet = map moduleImport initModules;
operator = m: map moduleImport (getImports m);
startSet = imap (moduleImport topLevel) initModules;
operator = m: imap (moduleImport m) (getImports m);
});
selectDeclsAndDefs = modules: