Profiling derivation graphs

I have a project (a flake, if that matters) that consists of a big graph of many small derivations for implementing incremental compilation. Is there any way or tool to profile such a graph so I can see what dependency edges I should try to remove to speed up builds? For example, it would be interesting to know the longest critical path (and/or its average length), that is, the path of derivations responsible for the overall build time assuming sufficient parallel jobs.

I see that Bazel has something like this among other useful-looking profiling tools. There is/was also Hubble, which solved this problem even more in-depth for some earlier version of Nix. Unfortunately, the --print-build-trace flag Hubble builds on seems to be long gone from the Nix source code.

7 Likes