lib/modules: add definitionsWithLocations to evaluated options

This attr provides the location of each definition.

This is particularly useful for introspecting options of type
`attrsOf`. E.g., it allows finding the location of a systemd
service definition by parsing
`options.systemd.services.definitionsWithLocations`.
This commit is contained in:
Erik Arvstedt 2022-09-05 12:11:43 +02:00
parent faf9c2b0a7
commit 9f22df9a7f
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -720,6 +720,7 @@ rec {
inherit (res.defsFinal') highestPrio;
definitions = map (def: def.value) res.defsFinal;
files = map (def: def.file) res.defsFinal;
definitionsWithLocations = res.defsFinal;
inherit (res) isDefined;
# This allows options to be correctly displayed using `${options.path.to.it}`
__toString = _: showOption loc;