We can now trivially obtain a Nix data structure that is a tree of the modules that took part in the evaluation of a configuration
Try it yourself! First, make sure of course that your Nixpkgs checkout includes the merged PR (which branches it landed in). Now, simply do something like
See that .graph attribute? That’s new . And everyone gets it for free . Normally, you’d access .config and thanks to the lazy nature of the language, if you don’t access .graph, its mere existence has practically no performance penalty, because it remains a thunk .
Explore the graph . It lets you know what modules took part in the evaluation of a configuration, be it NixOS, home-manager, nix-darwin, NixVim–whichever. It shows you which modules imported which other modules. For each module, several attributes are provided. Here’s an example snippet:
So, what can I do with it, you ask? Good question. Well, you might not care about this at all . But for example, I used it to find out which flake-parts module files contain NixOS modules that merge into flake.modules.nixos.pc (this option); otherwise, I would have had to use some unsound regex on my Nix code . Or, you could collect some statistics from the graph or draw a graphical tree (I’d love to see that).