summaryrefslogtreecommitdiffstats
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2019-12-05 03:29:51 +0100
committerSilvan Mosberger <contact@infinisil.com>2020-01-01 01:13:03 +0100
commit5414b4018bf1161ad9bd0e98d0ffbde8aa435fe5 (patch)
tree7272f147840b49cb2c36e500efc50f77ad847479 /lib/modules.nix
parent5002e6afbc70c6bf80efa5f997707b877cb59cdd (diff)
lib/modules: Don't pack submodules specially
This has the beneficial side effect of allowing paths to be used as modules in types.{submodule,submoduleWith}
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix26
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index 6bfc314991b2..48788ae933dd 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -103,7 +103,7 @@ rec {
toClosureList = file: parentKey: imap1 (n: x:
if isAttrs x || isFunction x then
let key = "${parentKey}:anon-${toString n}"; in
- unifyModuleSyntax file key (unpackSubmodule (applyIfFunction key) x args)
+ unifyModuleSyntax file key (applyIfFunction key x args)
else
let file = toString x; key = toString x; in
unifyModuleSyntax file key (applyIfFunction key (import x) args));
@@ -171,17 +171,6 @@ rec {
else
f;
- /* We have to pack and unpack submodules. We cannot wrap the expected
- result of the function as we would no longer be able to list the arguments
- of the submodule. (see applyIfFunction) */
- unpackSubmodule = unpack: m: args:
- if isType "submodule" m then
- { _file = m.file; } // (unpack m.submodule args)
- else unpack m args;
-
- packSubmodule = file: m:
- { _type = "submodule"; file = file; submodule = m; };
-
/* Merge a list of modules. This will recurse over the option
declarations in all modules, combining them into a single set.
At the same time, for each option declaration, it will merge the
@@ -267,7 +256,14 @@ rec {
'opts' is a list of modules. Each module has an options attribute which
correspond to the definition of 'loc' in 'opt.file'. */
- mergeOptionDecls = loc: opts:
+ mergeOptionDecls =
+ let
+ packSubmodule = file: m:
+ { _file = file; imports = [ m ]; };
+ coerceOption = file: opt:
+ if isFunction opt then packSubmodule file opt
+ else packSubmodule file { options = opt; };
+ in loc: opts:
foldl' (res: opt:
let t = res.type;
t' = opt.options.type;
@@ -293,9 +289,7 @@ rec {
current option declaration as the file use for the submodule. If the
submodule defines any filename, then we ignore the enclosing option file. */
options' = toList opt.options.options;
- coerceOption = file: opt:
- if isFunction opt then packSubmodule file opt
- else packSubmodule file { options = opt; };
+
getSubModules = opt.options.type.getSubModules or null;
submodules =
if getSubModules != null then map (packSubmodule opt._file) getSubModules ++ res.options