Nix Output Monitor

Pipe your nix-build output through the nix-output-monitor (aka nom) to get additional information while building.

Usage

The Easy Way

The nom binary (starting from version 2.0) behaves as a nix drop in, with much more colorful output, but only for the following commands:

nom build <args>: Behaves like nix build <args>.
nom shell <args>: Behaves like nix shell <args>.
nom develop <args>: Behaves like nix develop <args>.

The latter two commands work by calling nix shell or nix develop twice, the first time with overridden --run exit and monitoring the output, the second time passing output through to the user. This will incur a performance cost by doubling eval time.

Furthermore when called via the corresponding provided symlinks, nom is also a drop-in for the following commands:
nom-build <args>: Behaves like nix-build <args>.
nom-shell <args>: Behaves like nix-shell <args>.

All aliases internally use the json-based approach (see next section) and propagate error codes.

The Flexible Way

JSON based

nix-build --log-format internal-json -v |& nom --json

Warning: Don‘t forget to redirect stderr. That’s what the &, does.

Human readable log parsing

It is highly recommended to always append --log-format internal-json -v (or use the above mentioned aliases.) and call nom with --json. That will give you much more informative output.

If you are in a situation, where you can‘t use the json based nix output you can still use

nix-build |& nom

Warning: Don‘t forget to redirect stderr. That’s what the &, does.

This has the advantage to also work with other commands like nixos-rebuild or home-manager, where it is not trivial to pass in the --log-format internal-json -v flag. nom will pass everything it reads through, if it does not understand it. This makes it ideal to attach it to scripts which output more than just nix output.

Preserving Colored Text

Colored text will work as expected in json-mode.

In human-readable log mode you can preserve the color of the redirected text by using the unbuffer command from the expect package.

unbuffer nix-build |& nom

Explanation

Legend

Nom tries to convey information via symbols and colors

  • , yellow: running builds
  • , green: completed builds
  • , blue: planned builds
  • , red: failed builds
  • ↓ ⏵, yellow: running downloads
  • ↑ ⏵, yellow: running uploads
  • ↓ ✔, green: completed downloads
  • ↑ ✔, green: completed uploads
  • ↓ ⏸, blue: waiting downloads
  • : a moving average over past builds of this derivation
  • ⏱︎: running time
  • : a summary over all packages and hosts

If you can‘t see all icons you may need another terminal font. I recommend any font from pkgs.nerdfonts e.g. "JetBrainsMono Nerd Font". Also different terminals might work differently well. I recommend: pkgs.foot.

How to Read the Dependency Graph

  • Every entry in the nom tree stands for one derivation.
  • Children of a node are direct dependencies.
  • nom will try to show you the most relevant part of the dependency tree, roughly aiming to fill a third of your terminal
  • No build will be printed twice in the tree, it will only be shown for the lowermost dependency.
  • nom will do it’s best to print all running or failed builds, downloads and uploads, but it does not print every direct child of a node.
  • Use the colors from above to read the summary