A Rust port of nix-diff, a tool to explain why two Nix derivations differ.
- Compare two Nix derivations and show their differences
- Support for multiple input types:
.drvfiles (pre-built derivations)- Realized store paths
.nixfiles (will be instantiated automatically)- Flake references (e.g.,
nixpkgs#hello,path:/path/to/flake#package)
- Colored output with support for
NO_COLORenvironment variable - Delta-style inline word highlighting (shows what changed in each line)
- Minimal dependencies
nix run github:Mic92/nix-diff-rsnix-diff [OPTIONS] <INPUT1> <INPUT2>
Arguments:
<INPUT1> First input (.drv file, store path, .nix file, or flake#attr)
<INPUT2> Second input (.drv file, store path, .nix file, or flake#attr)
Options:
--color <MODE> Color mode: always, auto, never (default: auto)
--no-inline-highlight Disable word-level highlighting within changed lines
--context <LINES> Number of context lines (default: 3)
--input-list-limit <N> Max added/removed inputs to list (default: 10)
--depth <N> Max recursion depth into input derivations
-v, --verbose Show output-path changes and full input lists
-h, --help Show this help messageBy default, the output hides mechanical noise such as output-path changes
(which differ whenever anything else differs) and env vars that mirror
output paths ($out, $dev, ...). Use --verbose to show everything,
or --depth N to limit how deep the diff recurses into dependencies.
When color is enabled, changed words within changed lines are highlighted
with reverse-video (like delta or diff-so-fancy), so you can instantly
spot store-path hash changes and version bumps without scanning full lines.
Compare two derivations:
nix-diff /nix/store/abc123-hello.drv /nix/store/def456-hello.drvCompare realized store paths:
nix-diff /nix/store/abc123-hello /nix/store/def456-helloCompare Nix files (will be instantiated automatically):
nix-diff hello.nix goodbye.nixCompare flake outputs:
# Compare packages from flakes
nix-diff nixpkgs#hello nixpkgs#hello-wayland
# Compare local flake outputs
nix-diff .#packages.x86_64-linux.myapp .#packages.x86_64-linux.myapp-dev
# Compare using flake paths
nix-diff path:/path/to/flake1#package path:/path/to/flake2#packageLimit recursion depth (useful when stdenv changed and you only care about the top-level differences):
nix-diff --depth 1 nixpkgs/nixos-25.11#hello nixpkgs/nixos-unstable#helloDisable colors:
nix-diff --color never input1 input2
# or
NO_COLOR=1 nix-diff input1 input2# Enter development shell
nix develop
# Build
cargo build
# Run tests
cargo test
# Run benchmarks
cargo bench
# Format code
nix fmtBSD-3-Clause (same as the original nix-diff)
