diff --git a/lib/values/default.nix b/lib/values/default.nix index 8754d685c..6c2a0d7e7 100644 --- a/lib/values/default.nix +++ b/lib/values/default.nix @@ -36,7 +36,10 @@ let options = filteredSubOptions; modules = ( [ - { inherit options; } + { + inherit options; + _file = ""; + } ] ++ 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)) diff --git a/lib/values/test.nix b/lib/values/test.nix index fd519fcc7..e35934816 100644 --- a/lib/values/test.nix +++ b/lib/values/test.nix @@ -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