• Stars
    star
    632
  • Rank 69,326 (Top 2 %)
  • Language
    Haskell
  • License
    BSD 3-Clause "New...
  • Created almost 4 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interactively browse dependency graphs of Nix derivations.

nix-tree

Build Status Packaging status

Interactively browse dependency graphs of Nix derivations.

asciicast

Installation

nix-tree is on nixpkgs since 20.09, so just use your preferred method for adding packages to your system, eg:

nix-env -iA nix-tree

Or, for flake enabled systems:

nix profile install 'nixpkgs#nix-tree'

To run the current development version:

nix run github:utdemir/nix-tree -- --help

Usage

$ nix-tree --help
Usage: nix-tree [INSTALLABLE] [--store STORE] [--version] [--derivation] [--impure] [--dot]

  Interactively browse dependency graphs of Nix derivations.

Available options:
  INSTALLABLE              A store path or a flake reference.
                           Paths default to "~/.nix-profile" and "/var/run/current-system"
  --store STORE            The URL of the Nix store, e.g. "daemon" or "https://cache.nixos.org"
                           See "nix help-stores" for supported store types and settings.
  --version                Show the nix-tree version
  --derivation             Operate on the store derivation rather than its outputs
  --impure                 Allow access to mutable paths and repositories
  --dot                    Print the dependency graph in dot format
  -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 . | 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

Query the binary cache before download, with the --store option:

# Query the runtime dependency of `stellarium` (2 GiB closure) without download
nix eval --raw 'nixpkgs#stellarium.outPath' | xargs -o nix-tree --store https://cache.nixos.org

For valid --store options, see nix help-stores. For example,

# Build in a temporary chroot store and examine the output
nix build --store /tmp/chroot-store 'nixpkgs#hello' --print-out-paths | xargs -o nix-tree --store /tmp/chroot-store

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

More Repositories

1

ghc-musl

Docker image with GHC+musl for static executables
Shell
135
star
2

distributed-dataset

A distributed data processing framework in Haskell.
Haskell
115
star
3

hs-nix-template

A Haskell project template that uses Nix and comes with cabal-install, ghcid, ormolu, haskell-language-server and more.
Nix
101
star
4

dotfiles-nix

Comprehensive configurations of my NixOS workstations and home server.
Nix
84
star
5

nixlisp

Nix
59
star
6

bencoder

A simple bencode decoder-encoder library in pure Python.
Python
32
star
7

qualified-imports-plugin

Haskell
16
star
8

composable-indexes

Index arbitrary JavaScript objects with multiple dimensions.
TypeScript
9
star
9

hs-pivotal-tracker

A Haskell library and a CLI tool for interacting with Pivotal Tracker
Haskell
5
star
10

recursive-let-plugin

An experiment to implement something similar to RecursiveLet proposal using GHC plugins.
Haskell
4
star
11

zsh-up

ZSH integration for the Ultimate Plumber
Shell
4
star
12

utdemir.com

Source and build scripts for my personal website.
JavaScript
4
star
13

emacs-with-config

A Nix function for customizing Emacs
Emacs Lisp
4
star
14

handsy

[DEPRECATED] A Haskell DSL to describe common shell operations and interpeters for running them locally and remotely.
Haskell
4
star
15

bar

Configurable progress bars/status monitors for Python console applications.
Python
4
star
16

midye

Haskell
4
star
17

thlpe

Haskell implementation of "The Hardest Logic Puzzle Ever"
Haskell
2
star
18

hamza

Haskell
2
star
19

dotfiles

Dotfiles for my Macbook
Shell
2
star
20

qrpush

Simple application for transferring files to a smart phone.
Ruby
2
star
21

talks

Nix
2
star
22

serverless-hs

A Haskell web framework that runs on AWS Lambda. Currently incomplete, large parts are missing, nothing is working.
Haskell
2
star
23

aoc2022

Haskell
1
star
24

network-transport-websockets

A websocket transport implementing network-transport API
Haskell
1
star
25

trying-yi

Haskell
1
star
26

allrgb

Scala
1
star
27

lmdb-safe

A bit safer lmdb binding for Haskell.
Haskell
1
star
28

apidoc-hs

Generate Haskell data types from Apidoc schemas using Template Haskell.
Haskell
1
star
29

gcal-i-am-busy

Nix
1
star
30

furby

A simplified rawdog clone, in Ruby
HTML
1
star
31

cookiecutter-haskell

Nix
1
star