From 37ce2ca949e389ea2106ad596b3f0bfc3313e468 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Tue, 15 Sep 2009 00:21:39 +0000 Subject: [PATCH] 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 --- pkgs/lib/modules.nix | 20 +++++++++----------- 1 file 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: