From 9f22df9a7f575a172bfd222e9c01296bc9df3e6d Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Mon, 5 Sep 2022 12:11:43 +0200 Subject: [PATCH] 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`. --- lib/modules.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/modules.nix b/lib/modules.nix index d3a7fac82c4a..b6751d17f8f4 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -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;