$ show Gabriella439/nix-diff
nix-diff is a Haskell-based CLI tool that compares two Nix derivations (.drv files) or store paths and explains why they differ. It provides both human-readable and JSON output formats, with options to control the diff granularity (word/line/character oriented), limit context, and apply transformations to simplify large diffs. The architecture separates concerns into core diff logic (src/Nix/Diff.hs), data types (Types.hs), diff simplification transformations (Transformations.hs), store abstraction (Store.hs), and rendering (Render/HumanReadable.hs). The tool uses memoization to avoid redundant comparisons and handles relocated Nix stores via the NIX_REMOTE environment variable.
The LLM identified 2 files worth highlighting for reuse:
Defines the core data structures for representing derivation differences, including recursive types for nested diffs. Demonstrates skilled use of Haskell's type system with proper JSON serialization/deserialization instances. The module is self-contained with minimal dependencies (aeson, text, containers) and could be reused in other projects needing to represent and serialize tree-structured differences.
Provides functions to simplify complex derivation diffs by folding already compared subtrees and squashing repetitive text/environment differences. Shows non-obvious skill in handling large diffs intelligently to prevent overwhelming output. The foldAlreadyComparedSubTrees and foldManyInputDerivationsAlreadyCompared functions are particularly noteworthy for making diffs readable while preserving essential information. Pure functions with minimal dependencies make this highly reusable.