statix
2 min read

Lints and suggestions for Nix code. statix check highlights antipatterns, statix fix auto-corrects them. Works on AST level only — no evaluation.

Usage

bash
# scan a directory recursively
statix check /path/to/dir

# ignore generated files
statix check . -i Cargo.nix .direnv

# disable .gitignore-based filtering
statix check . -u

# auto-fix in-place
statix fix /path/to/file

# dry run (show diff only)
statix fix --dry-run /path/to/file

Output formats

bash
statix check . -o json # machine-readable
statix check . -o errfmt # single-line, vim-friendly

Configuration

Create statix.toml at the project root to disable specific lints:

toml
# statix.toml
disabled = [
"empty_pattern",
"unquoted_uri",
]

statix walks up parent directories to find statix.toml, or pass it explicitly with --config.

Generate a base config: statix dump > statix.toml

Lints

CodeNameDescription
W01bool_comparisonx == true → x
W02empty_let_inlet in block with no bindings
W03manual_inheritx = x; → inherit x;
W04manual_inherit_fromx = foo.x; → inherit (foo) x;
W05legacy_let_syntaxold let { } form
W06collapsible_let_innested let in that can be merged
W07eta_reductionx: f x → f
W08useless_parensunnecessary parentheses
W10empty_pattern{ }: with no args used
W11redundant_pattern_bind@-bind that is never used
W12unquoted_uribare URI literal (deprecated syntax)
W13deprecated_is_nullx == null → isNull x (or vice versa)
W14empty_inheritinherit; with nothing inherited
W15faster_groupbysuboptimal groupBy pattern
W16faster_zipattrswithsuboptimal zipAttrsWith pattern
W17deprecated_to_pathuse of deprecated toPath
W18bool_simplificationredundant boolean logic
W19useless_has_attr? check that is always true/false
W20repeated_keysduplicate keys in attrset
W23empty_list_concat[] ++ x or x ++ []

Installation

bash
# from nixpkgs
nix run nixpkgs#statix -- help

# from source (flake)
nix run git+https://git.peppe.rs/languages/statix -- --help