summaryrefslogtreecommitdiffstats
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 17:24:14 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 22:45:57 +0100
commit9a8516438e93ec61bc37fc6f2e1125df30df2f4b (patch)
tree35c67f00a5bce895512553c8cc69f6fc07ac3a33 /lib/modules.nix
parent259f7a93b1e679b73026352b40029375aa94db7c (diff)
Fix NixOps evaluation
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 47c7e9bf1ac3..5c5820e92f45 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -22,35 +22,37 @@ rec {
/* Close a set of modules under the ‘imports’ relation. */
closeModules = modules: args:
let
- toClosureList = parent: imap (n: x:
+ toClosureList = file: parentKey: imap (n: x:
if isAttrs x || builtins.isFunction x then
- unifyModuleSyntax parent "anon-${toString n}" (applyIfFunction x args)
+ unifyModuleSyntax file "${parentKey}:anon-${toString n}" (applyIfFunction x args)
else
unifyModuleSyntax (toString x) (toString x) (applyIfFunction (import x) args));
in
builtins.genericClosure {
- startSet = toClosureList unknownModule modules;
- operator = m: toClosureList m.file m.imports;
+ startSet = toClosureList unknownModule "" modules;
+ operator = m: toClosureList m.file m.key m.imports;
};
/* Massage a module into canonical form, that is, a set consisting
of ‘options’, ‘config’ and ‘imports’ attributes. */
unifyModuleSyntax = file: key: m:
if m ? config || m ? options || m ? imports then
- let badAttrs = removeAttrs m ["imports" "options" "config"]; in
+ let badAttrs = removeAttrs m ["imports" "options" "config" "key"]; in
if badAttrs != {} then
throw "Module `${key}' has an unsupported attribute `${head (attrNames badAttrs)}'. ${builtins.toXML m} "
else
- { inherit file key;
+ { inherit file;
+ key = m.key or key;
imports = m.imports or [];
options = m.options or {};
config = m.config or {};
}
else
- { inherit file key;
+ { inherit file;
+ key = m.key or key;
imports = m.require or [];
options = {};
- config = removeAttrs m ["require"];
+ config = removeAttrs m ["key" "require"];
};
applyIfFunction = f: arg: if builtins.isFunction f then f arg else f;