deadnix

Scans .nix files for unused variable bindings — let bindings, lambda args, lambda pattern names, inherited values. Can auto-remove them in-place.

Usage

# scan current directory
nix run github:astro/deadnix -- .
 
# auto-fix in-place (commit first!)
nix run github:astro/deadnix -- -eq .

Key flags

FlagDescription
-e / --editremove dead code in-place
-f / --failexit 1 if dead code found (CI)
-L / --no-lambda-pattern-namesskip pattern name checks — needed for nixpkgs callPackage
-l / --no-lambda-argskip lambda argument checks
-_ / --no-underscoreignore bindings starting with _
-o jsonmachine-readable output
--excludeexclude specific files/paths

Suppress a specific binding

# deadnix: skip
unusedThing = ...;