lib/values: fix submodule and submoduleWith with external modules
This commit is contained in:
@@ -36,7 +36,10 @@ let
|
||||
options = filteredSubOptions;
|
||||
modules = (
|
||||
[
|
||||
{ inherit options; }
|
||||
{
|
||||
inherit options;
|
||||
_file = "<artifical submodule>";
|
||||
}
|
||||
]
|
||||
++ map (config: { inherit config; }) defs.${attrName}
|
||||
);
|
||||
@@ -63,13 +66,7 @@ let
|
||||
|
||||
submodulePrios =
|
||||
let
|
||||
options = filteredSubOptions;
|
||||
modules = (
|
||||
[
|
||||
{ inherit options; }
|
||||
]
|
||||
++ opt.definitions
|
||||
);
|
||||
modules = (opt.definitions ++ opt.type.getSubModules);
|
||||
submoduleEval = lib.evalModules {
|
||||
inherit modules;
|
||||
};
|
||||
@@ -80,8 +77,8 @@ let
|
||||
if opt ? type && opt.type.name == "submodule" then
|
||||
(prio) // submodulePrios
|
||||
else if opt ? type && opt.type.name == "attrsOf" then
|
||||
prio // (
|
||||
prioPerValue {
|
||||
prio
|
||||
// (prioPerValue {
|
||||
type = opt.type;
|
||||
defs = zipDefs opt.definitions;
|
||||
} (lib.modules.mergeAttrDefinitionsWithPrio opt))
|
||||
|
||||
@@ -130,6 +130,42 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
test_submoduleWith =
|
||||
let
|
||||
evaluated = (
|
||||
eval [
|
||||
{
|
||||
options.foo = lib.mkOption {
|
||||
type = lib.types.submoduleWith {
|
||||
modules = [
|
||||
{
|
||||
options.bar = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
foo.bar = false;
|
||||
}
|
||||
]
|
||||
);
|
||||
in
|
||||
{
|
||||
inherit evaluated;
|
||||
expr = slib.getPrios {
|
||||
options = evaluated.options;
|
||||
};
|
||||
expected = {
|
||||
foo = {
|
||||
__prio = 100;
|
||||
bar.__prio = 100; # Set via other module
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# TODO(@hsjobeki): Cover this edge case
|
||||
# test_freeform =
|
||||
# let
|
||||
|
||||
Reference in New Issue
Block a user