lib/introspect: fix list item meta

This commit is contained in:
Johannes Kirschbauer
2025-10-02 16:40:29 +02:00
parent 1a8131f17f
commit 6f5f182aef
2 changed files with 64 additions and 1 deletions

View File

@@ -125,7 +125,7 @@ let
/** /**
Maps attrsOf and lazyAttrsOf Maps attrsOf and lazyAttrsOf
*/ */
handleListOf = list: { __list = lib.map handleMeta { meta = list; }; }; handleListOf = list: { __list = lib.map (item: handleMeta { meta = item; }) list; };
/** /**
Unwraps the valueMeta of an option based on its type Unwraps the valueMeta of an option based on its type

View File

@@ -576,6 +576,69 @@ in
}; };
}; };
}; };
test_listof_submodule_list =
let
evaluated = eval [
{
options.list = lib.mkOption {
type = lib.types.listOf (
lib.types.submodule {
options = {
foo = lib.mkOption { };
};
}
);
};
}
({
_file = "inventory.json";
list = [
# Incomplete entry, should not break introspection
{ }
{ }
];
})
({
_file = "clan.nix";
list = [
{ }
{ }
];
})
];
in
{
inherit evaluated;
expr = (slib.getPrios { options = evaluated.options; });
expected = {
list = {
__list = lib.genList (_: {
foo = {
__this = {
files = [ ];
headType = "unspecified";
nullable = false;
prio = 9999;
total = false;
};
};
}) 4;
__this = {
files = [
"clan.nix"
"inventory.json"
];
headType = "listOf";
nullable = false;
prio = 100;
total = false;
};
};
};
};
test_listOf_submodule_default = test_listOf_submodule_default =
let let
evaluated = eval [ evaluated = eval [