From 21358e7ad02e3c6c93451307ffe9c9ca9acfb995 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 5 Jan 2010 17:04:55 +0000 Subject: [PATCH] * Support require/imports in top-level anonymous configurations, i.e. the elements of initModules that are not paths. * Support a "key" attribute in anonymous configurations to allow lazyGenericClosure to distinguish between them. svn path=/nixpkgs/trunk/; revision=19240 --- pkgs/lib/modules.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/lib/modules.nix b/pkgs/lib/modules.nix index 4500d588a02..3808893c14f 100644 --- a/pkgs/lib/modules.nix +++ b/pkgs/lib/modules.nix @@ -51,7 +51,7 @@ rec { getImportedSets = m: filter (x: !isPath x) (getImports m); getConfig = m: - removeAttrs (delayProperties m) ["require"]; + removeAttrs (delayProperties m) ["require" "key"]; in if isModule m then { key = ""; } // m @@ -81,18 +81,19 @@ rec { moduleClosure = initModules: args: let moduleImport = m: - (unifyModuleSyntax (applyIfFunction (importIfPath m) args)) // { + let m' = applyIfFunction (importIfPath m) args; + in (unifyModuleSyntax m') // { # used by generic closure to avoid duplicated imports. - key = if isPath m then m else ""; + key = if isPath m then m else if m' ? key then m'.key else ""; }; getImports = m: attrByPath ["imports"] [] m; in (lazyGenericClosure { - startSet = map moduleImport (filter isPath initModules); + startSet = map moduleImport initModules; operator = m: map moduleImport (getImports m); - }) ++ (map moduleImport (filter (m: ! isPath m) initModules)); + }); selectDeclsAndDefs = modules: lib.concatMap (m: