I'd expect imports to work in types.submodule the same as in submoduleWith
Very often i use type = submodule module because it is more convenient to write than type = submoduleWith { modules = toList module; }
Since i knew that submodule is an abstraction over submoduleWith i would expect both to behave the same by default.
The weirdness is that they don't and that people wanted to decompose their submodules into multiple files which is not possible with plain types.submodule
# Doesnt evaluate
eval = evalModules {
modules = [
{
options.foo = lib.mkOption {
type = lib.types.submodule {
options.bar = mkOption {
type = types.str;
};
};
};
config.foo = {
# since shorthandsOnlyDefines config is true on submodule this actually sets config.imports
imports = [
{ bar = "bar"; }
];
};
}
];
};
Possible solutions:
Idea1:
- deprecate
types.submodule (People should be warned that their modules behave differently)
- add
types.submoduleOf (or similar)
Idea2:
- disallow
imports (and probably options config and other reserved names?)
- forward
imports = config.imports
I'd expect
importsto work in types.submodule the same as in submoduleWithVery often i use
type = submodule modulebecause it is more convenient to write thantype = submoduleWith { modules = toList module; }Since i knew that
submoduleis an abstraction oversubmoduleWithi would expect both to behave the same by default.The weirdness is that they don't and that people wanted to decompose their submodules into multiple files which is not possible with plain
types.submodulePossible solutions:
Idea1:
types.submodule(People should be warned that their modules behave differently)types.submoduleOf(or similar)Idea2:
imports(and probablyoptionsconfigand other reserved names?)imports = config.imports