diff options
author | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-09-15 00:21:39 +0000 |
---|---|---|
committer | Nicolas Pierron <nicolas.b.pierron@gmail.com> | 2009-09-15 00:21:39 +0000 |
commit | 37ce2ca949e389ea2106ad596b3f0bfc3313e468 (patch) | |
tree | 941b6bb42122587784ea901ec95f54efdabd3cc0 | |
parent | a593492d4f6b9cde1e3a8e7d710d5d10b03b7718 (diff) | |
download | nixlib-37ce2ca949e389ea2106ad596b3f0bfc3313e468.tar nixlib-37ce2ca949e389ea2106ad596b3f0bfc3313e468.tar.gz nixlib-37ce2ca949e389ea2106ad596b3f0bfc3313e468.tar.bz2 nixlib-37ce2ca949e389ea2106ad596b3f0bfc3313e468.tar.lz nixlib-37ce2ca949e389ea2106ad596b3f0bfc3313e468.tar.xz nixlib-37ce2ca949e389ea2106ad596b3f0bfc3313e468.tar.zst nixlib-37ce2ca949e389ea2106ad596b3f0bfc3313e468.zip |
Handles cases where developers ""cannot"" put their initial modules in
other files. Imports of imported attribute set are not working anymore because this feature is hard to maintain and because this a potential source of error. Imports are only accepted inside named modules where the system has some control over mutual inclusion. svn path=/nixpkgs/trunk/; revision=17144
-rw-r--r-- | pkgs/lib/modules.nix | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/pkgs/lib/modules.nix b/pkgs/lib/modules.nix index 7e1d2f9d56f3..61cf7624bc55 100644 --- a/pkgs/lib/modules.nix +++ b/pkgs/lib/modules.nix @@ -64,22 +64,20 @@ rec { moduleClosure = initModules: args: let - moduleImport = m: lib.addErrorContext - "Import module ${(if builtins.isAttrs m then "{...}" else m)}." ( - (unifyModuleSyntax (applyIfFunction - (if builtins.isAttrs m then m else import m) args)) // { + moduleImport = m: + (unifyModuleSyntax (applyIfFunction (importIfPath m) args)) // { # used by generic closure to avoid duplicated imports. - key = m; - paths = [ m ]; - } - ); + key = if isPath m then m else + /bad/developer/implies/bad/error/messages; + }; getImports = m: attrByPath ["imports"] [] m; + in - lazyGenericClosure { - startSet = map moduleImport initModules; + (lazyGenericClosure { + startSet = map moduleImport (filter isPath initModules); operator = m: map moduleImport (getImports m); - }; + }) ++ (map moduleImport (filter (m: ! isPath m) initModules)); selectDeclsAndDefs = modules: lib.concatMap (m: |