diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2011-04-27 18:41:37 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2011-04-27 18:41:37 +0000 |
commit | 02677481aeaf1e861b9b3456a9086c34a51550d7 (patch) | |
tree | bb7b232e9a8293d4a32d4fe4bd4584cac7a11267 /pkgs/lib | |
parent | 85d3fd3e3cf6a7cd2ec361b3bb996f8587f8c34c (diff) |
modules (moduleClosure): use imap instead of map to produce uniq keys for
the genericClosure. svn path=/nixpkgs/trunk/; revision=27014
Diffstat (limited to 'pkgs/lib')
-rw-r--r-- | pkgs/lib/modules.nix | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/pkgs/lib/modules.nix b/pkgs/lib/modules.nix index 08c26e72f72ea..8ecb04156e78c 100644 --- a/pkgs/lib/modules.nix +++ b/pkgs/lib/modules.nix @@ -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: |