mirror of
https://github.com/utdemir/nix-tree.git
synced 2024-09-11 14:55:44 +03:00
Interactively browse dependency graphs of Nix derivations.
Flake lock file updates: • Updated input 'flake-compat': 'github:edolstra/flake-compat/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9' (2023-01-17) → 'github:edolstra/flake-compat/0f9255e01c2351cc7d116c072cb317785dd33b33' (2023-10-04) • Updated input 'flake-utils': 'github:numtide/flake-utils/cfacdce06f30d2b68473a46042957675eebb3401' (2023-04-11) → 'github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384' (2023-09-12) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/87f9156865ab09e3bde39aadb4131ae364ae704e' (2023-05-24) → 'github:nixos/nixpkgs/5aabb5780a11c500981993d49ee93cfa6df9307b' (2023-10-08) |
||
---|---|---|
.github/workflows | ||
src | ||
test | ||
.gitignore | ||
asciicast.sh | ||
CHANGELOG.md | ||
default.nix | ||
flake.lock | ||
flake.nix | ||
format.sh | ||
LICENSE | ||
nix-tree.cabal | ||
README.md | ||
shell.nix |
nix-tree
Interactively browse dependency graphs of Nix derivations.
Installation
nix-tree
is on nixpkgs
since 20.09
, so just use your preferred method for adding packages to your system, eg:
nix-env -i nix-tree
To run the current development version:
nix run github:utdemir/nix-tree -- --help
Usage
$ nix-tree --help
Usage: nix-tree [--version] [--derivation] [INSTALLABLE]
Interactively browse dependency graphs of Nix derivations.
Available options:
--version Show the nix-tree version.
--derivation Operate on the store derivation rather than its
outputs.
INSTALLABLE A store path or a flake reference. Paths default to
"~/.nix-profile" and "/var/run/current-system".
-h,--help Show this help text
Keybindings:
hjkl/Arrow Keys : Navigate
w : Open why-depends mode
/ : Open search mode
s : Change sort order
y : Yank selected path to clipboard
? : Show help
q/Esc : Quit / close modal
Glossary
- NAR Size: Size of the store path itself.
- Closure size: Total size of the store path and all its transitive dependencies.
- Added size: Size of the store path, and all its unique transitive dependencies. In other words, the cost of having that store path on top of all other paths. See issue #14 for a better explanation.
Tips
nix-build
prints built paths to stdout, which can be piped conveniently
with | xargs -o nix-tree
. Examples:
# Output of a local derivation
nix-build . --no-out-link | xargs -o nix-tree
# Build time dependencies (passing a `.drv` path)
nix-instantiate -r | xargs -o nix-tree --derivation
# Dependencies from shell.nix
nix-build shell.nix -A inputDerivation | xargs -o nix-tree
# All outputs of a derivation in nixpkgs:
nix-build '<nixpkgs>' -A openssl.all --no-out-link | xargs -o nix-tree
nix-tree
also supports flake references:
# Build time dependencies of a flake on the current directory
nix-tree --derivation '.#'
# Same thing works for any flake reference
nix-tree --derivation 'nixpkgs#asciiquarium'
Run nix-tree
on your current nixos system:
nix-tree /nix/var/nix/profiles/system
Contributing
All contributions, issues and feature requests are welcome.
To hack on it, simply run nix-shell
and use cabal
as usual. Please run ./format.sh
before sending a PR.
Related tools
- nix-du: Visualise which gc-roots to delete to free some space in your nix store
- nix-melt: A ranger-like flake.lock viewer
- nix-query-tree-viewer: GTK viewer for the output of
nix-store --query --tree
- nix-visualize: Uses the Nix package manager to visualize the dependencies of a given package