I recently switched to the dendritic design pattern with flake parts and needed a way to understand my module structure:
- Which modules get imported from other modules?
- Which modules get declared in what files?
Manually tracing these relationships through code was tedious and error-prone, so I built this tool to visualize the module dependency graph.
This tool leverages the new .graph output introduced in the Nixpkgs module system.
Thanks to this merged PR, we can now obtain a JSON representing the tree of modules that took part in the evaluation of a configuration.
For more details, see the announcement on NixOS Discourse.
Tip
You can also use nix run github:giomf/nixoscope instead of cloning this repository and executing nixoscope.py
nix eval --json '.#nixosConfigurations.<your-config>.graph' > graph.json
nixoscope.py --input graph.json
default: graph.json
nixoscope.py --format gv
default: gv
nixoscope.py --format json
default: gv
nixoscope.py --option "flake.modules"
This project uses AI as an aid.