Nix-tree: Interactively browse the dependency graph of your Nix derivations

I noticed that I spent a lot of time digging into the transitive dependencies of a store path, usually to trim down the closure size. So, I ended up creating a small terminal application to make it a bit easier.

Easiest way to understand what it is is to watch this console recording:

asciicast

In case anyone else finds it useful: https://github.com/utdemir/nix-tree

I’m open to suggestions, bug reports or contributions.

Edit: This project has been renamed to “nix-tree”. (It used to be “nixdu”)

19 Likes

Sweet! Any idea how to convince home-manager to install it?

Awesome! I’ve always wanted to have such a tool. Reminds me of my crufty too long command that I always used that did something similar:

du -csh /nix/store/* | sort -rh | fzf --preview-window=right --preview='printf "\n%s\n" "@@@ $(du -sh {2}) @@@"; printf "\n%s\n" "@@@ referrers @@@"; nix-store -q --referrers {2}; printf "\n%s\n" "@@@ references @@@"; nix-store -q --references {2}' | awk '{print $2}'

Thank you :heart: so much for creating this. I’d love to see this in Nixpkgs or in the NUR. Also, I give you :star: :star: :star: :star: :star: for making nixdu it self a 4 references derivation :wink:

I just added an overlay, so it should now can be with home-manager like:

nixpkgs.overlays = [
  (let url = https://github.com/utdemir/nixdu/archive/master.tar.gz;
    in import "${builtins.fetchTarball url}/overlay.nix" {})
];

home.packages = [ pkgs.nixdu ];

(I also added this example to README).

I haven’t tried this, so please let me know if this doesn’t work.

2 Likes

Here’s how I did it:

niv add utdemir/nixdu

then: https://github.com/ryantm/dotfiles/commit/0ca66bbaa6cb08750c0df7c28fbceba10e5b16bf

My dotfiles use a similar setup to home-manager template

Related tool with a very similar name: https://github.com/symphorien/nix-du

Oh, that is my mistake, sorry. I should’ve checked before. I will mention that in the README.

Thinking about it, I decided to rename this project to nix-tree. Thank you for letting me know @lheckemann.