statix
Lints and suggestions for Nix code. statix check highlights antipatterns, statix fix auto-corrects them. Works on AST level only — no evaluation.
Usage
# 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/fileOutput formats
statix check . -o json # machine-readable
statix check . -o errfmt # single-line, vim-friendlyConfiguration
Create statix.toml at the project root to disable specific lints:
# 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
| Code | Name | Description |
|---|---|---|
| W01 | bool_comparison | x == true → x |
| W02 | empty_let_in | let in block with no bindings |
| W03 | manual_inherit | x = x; → inherit x; |
| W04 | manual_inherit_from | x = foo.x; → inherit (foo) x; |
| W05 | legacy_let_syntax | old let { } form |
| W06 | collapsible_let_in | nested let in that can be merged |
| W07 | eta_reduction | x: f x → f |
| W08 | useless_parens | unnecessary parentheses |
| W10 | empty_pattern | { }: with no args used |
| W11 | redundant_pattern_bind | @-bind that is never used |
| W12 | unquoted_uri | bare URI literal (deprecated syntax) |
| W13 | deprecated_is_null | x == null → isNull x (or vice versa) |
| W14 | empty_inherit | inherit; with nothing inherited |
| W15 | faster_groupby | suboptimal groupBy pattern |
| W16 | faster_zipattrswith | suboptimal zipAttrsWith pattern |
| W17 | deprecated_to_path | use of deprecated toPath |
| W18 | bool_simplification | redundant boolean logic |
| W19 | useless_has_attr | ? check that is always true/false |
| W20 | repeated_keys | duplicate keys in attrset |
| W23 | empty_list_concat | [] ++ x or x ++ [] |
Installation
# from nixpkgs
nix run nixpkgs#statix -- help
# from source (flake)
nix run git+https://git.peppe.rs/languages/statix -- --help