| * My MRE attempt is producing the expected behavior:
nix-repl> (lib.modules.mergeDefinitions [] result.list-type' [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]
nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.list'.type [ { file = "."; value = ["a"]; } { file = "."; value = ["b"]; } ]).mergedValue
[ "a'" "b'" ]
nix-repl> (lib.modules.mergeDefinitions [] result.attrs-type' [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }
nix-repl> (lib.modules.mergeDefinitions [] result.configuration.options.attrs'.type [ { file = "."; value = { a = "a"; }; } { file = "."; value = { b = "b"; }; } ]).mergedValue
{ a = "a'"; b = "b'"; }
So I'm struggling to understand why in #2342 I have issues where the the type behaves differently after being used in evalModules and/or listOf:
nix-repl> (lib.modules.mergeDefinitions [] lib.nixvim.keymaps.deprecatedMapOptionSubmodule [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }
nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType [ { file = "."; value ={ action = "b"; key = "a"; lua = «error: error:
… while evaluating the attribute 'value'
at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:
820| in warnDeprecation opt //
821| { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
822| inherit (res.defsFinal') highestPrio;
… while calling the 'addErrorContext' builtin
at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:
820| in warnDeprecation opt //
821| { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
822| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: The option `lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }
nix-repl> builtins.head (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type [ { file = "."; value = [{key = "a"; action = "b";}]; } { file = "."; value = [{ key = "c"; action = "d";}]; } ]).mergedValue
{ action = "b"; key = "a"; lua = «error: error:
… while evaluating the attribute 'value'
at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:9:
820| in warnDeprecation opt //
821| { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
822| inherit (res.defsFinal') highestPrio;
… while calling the 'addErrorContext' builtin
at /nix/store/fpivx4sjcp2vk4rp9nhliln5cwcp3kc6-source/lib/modules.nix:821:17:
820| in warnDeprecation opt //
821| { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
| ^
822| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: The option `"[definition 1-entry 1]".lua' was accessed but has no value defined. Try setting the option.»; mode = ""; options = { ... }; }
NOTE: legacyPackages.x86_64-linux.nixvimConfiguration.options.keymaps.type.nestedTypes.elemType and lib.nixvim.keymaps.deprecatedMapOptionSubmodule should be the same thing, but one works correctly while the other does not.
The keymaps option is literally defined as:
keymaps = lib.mkOption {
type = lib.types.listOf lib.nixvim.keymaps.deprecatedMapOptionSubmodule;
# ...
}
EDIT: Accessing lib via special args also does not produce the issue (i.e. works correctly):
nix-repl> (lib.modules.mergeDefinitions [] legacyPackages.x86_64-linux.nixvimConfiguration._module.specialArgs.lib.nixvim.keymaps.deprecatedMapOptionSubmodule [ { file = "."; value = {key = "a"; action = "b";}; } ]).mergedValue
{ action = "b"; key = "a"; mode = ""; options = { ... }; }
|