Support "imports" in abbreviated modules

In abbreviated modules (those without a "config" attribute), you can
use "require", but it doesn't behave in the same way.  For consistency
we should use "imports" everywhere.
This commit is contained in:
Eelco Dolstra 2013-09-04 11:49:56 +02:00
parent e55c0bcaaa
commit 62585a363f

View file

@ -46,25 +46,21 @@ rec {
unifyModuleSyntax = m:
let
delayedModule = delayProperties m;
getImports =
if m ? config || m ? options then
m.imports or []
else
toList (rmProperties (delayedModule.require or []));
getImports =
toList (rmProperties (delayedModule.require or []));
getImportedPaths = filter isPath getImports;
getImportedSets = filter (x: !isPath x) getImports;
getConfig =
removeAttrs delayedModule ["require" "key"];
removeAttrs delayedModule ["require" "key" "imports"];
in
if isModule m then
{ key = "<unknown location>"; } // m
else
{
key = "<unknown location>";
imports = getImportedPaths;
{ key = "<unknown location>";
imports = (m.imports or []) ++ getImportedPaths;
config = getConfig;
} // (
if getImportedSets != [] then