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 \
  • Remove reference to a dependency manually using remove-references-to.

Cleaning up after Cabal using remove-references-to

Some examples: