Nix derivation dependency graph

I recently had to debug a problem wherein a Haskell binary created using Nix was created with a runtime dependency on the entire GHC ecosystem (despite using justStaticExecutables). This investigation led to identifying Cabal’s Paths_* module autogeneration as the root cause.

The following commands came in handy when investigating the problem, which was fixed (as a workaround) using remove-references-to.

Useful commands

  • Get the dependency tree:

    nix-store -q --tree result
  • Ask “why” as to a particular dependency:

    nix why-depends -a ./result \
     /nix/store/bicv5nnibqg0qsqyjvb3nw01447yms0j-shake-0.18.5-data
  • Remove reference to a dependency manually using remove-references-to.

Cleaning up after Cabal using remove-references-to

Some examples: