Merge branch 'allow-imports-in-submodules' into upstream-master
This allows submodules to use the full power of the module system. Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
commit
8179bad658
@ -75,12 +75,19 @@ rec {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
unifyOptionModule = {key ? "<unknown location>"}: m: (args:
|
unifyOptionModule = {key ? "<unknown location>"}: name: index: m: (args:
|
||||||
let module = lib.applyIfFunction m args; in
|
let
|
||||||
if lib.isModule module then
|
module = lib.applyIfFunction m args;
|
||||||
{ inherit key; } // module
|
key_ = rec {
|
||||||
|
file = key;
|
||||||
|
option = name;
|
||||||
|
number = index;
|
||||||
|
outPath = key;
|
||||||
|
};
|
||||||
|
in if lib.isModule module then
|
||||||
|
{ key = key_; } // module
|
||||||
else
|
else
|
||||||
{ inherit key; options = module; }
|
{ key = key_; options = module; }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -197,9 +204,9 @@ rec {
|
|||||||
recurseInto = name:
|
recurseInto = name:
|
||||||
moduleMerge (addName name) (modulesOf name);
|
moduleMerge (addName name) (modulesOf name);
|
||||||
|
|
||||||
recurseForOption = name: modules:
|
recurseForOption = name: modules: args:
|
||||||
moduleMerge name (
|
moduleMerge name (
|
||||||
map unifyModuleSyntax modules
|
moduleClosure modules args
|
||||||
);
|
);
|
||||||
|
|
||||||
errorSource = modules:
|
errorSource = modules:
|
||||||
@ -240,7 +247,7 @@ rec {
|
|||||||
decls = # add location to sub-module options.
|
decls = # add location to sub-module options.
|
||||||
map (m:
|
map (m:
|
||||||
mapSubOptions
|
mapSubOptions
|
||||||
(unifyOptionModule {inherit (m) key;})
|
(unifyOptionModule {inherit (m) key;} name)
|
||||||
m.options
|
m.options
|
||||||
) declarations;
|
) declarations;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ rec {
|
|||||||
mapSubOptions = f: opt:
|
mapSubOptions = f: opt:
|
||||||
if opt ? options then
|
if opt ? options then
|
||||||
opt // {
|
opt // {
|
||||||
options = map f (toList opt.options);
|
options = imap f (toList opt.options);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
opt;
|
opt;
|
||||||
@ -82,16 +82,18 @@ rec {
|
|||||||
handleOptionSets = opt:
|
handleOptionSets = opt:
|
||||||
if opt ? type && opt.type.hasOptions then
|
if opt ? type && opt.type.hasOptions then
|
||||||
let
|
let
|
||||||
|
|
||||||
optionConfig = vals: args:
|
|
||||||
map (f: lib.applyIfFunction f args)
|
|
||||||
(opt.options ++ toList vals);
|
|
||||||
|
|
||||||
# Evaluate sub-modules.
|
# Evaluate sub-modules.
|
||||||
subModuleMerge = path: vals:
|
subModuleMerge = path: vals:
|
||||||
lib.fix (args:
|
lib.fix (args:
|
||||||
let
|
let
|
||||||
result = recurseInto path (optionConfig vals args);
|
result = recurseInto path (opt.options ++ imap (index: v: args: {
|
||||||
|
key = rec {
|
||||||
|
#!!! Would be nice if we had the file the val was from
|
||||||
|
option = path;
|
||||||
|
number = index;
|
||||||
|
outPath = "option ${option} config number ${toString number}";
|
||||||
|
};
|
||||||
|
} // (lib.applyIfFunction v args)) (toList vals)) args;
|
||||||
name = lib.removePrefix (opt.name + ".") path;
|
name = lib.removePrefix (opt.name + ".") path;
|
||||||
extraArgs = opt.extraArgs or {};
|
extraArgs = opt.extraArgs or {};
|
||||||
individualExtraArgs = opt.individualExtraArgs or {};
|
individualExtraArgs = opt.individualExtraArgs or {};
|
||||||
|
Loading…
Reference in New Issue
Block a user