A fast semantic linter for Nix using tree-sitter π³ + βοΈ. [maintainers=@Artturin,@siraben]
Rust
176
134 commits
updated Jun 22, 2026
This is a semantic linter for Nixpkgs that uses tree-sitter. Currently we have the following detections:
cmake, makeWrapper, pkg-config in buildInputsstdenv in nativeBuildInputsnixpkgs-lint can easily handle multi-line
expressions, eliminates false-positives from strings and comments
and gives exact spans for matchesTo use without installing, run nix run github:nix-community/nixpkgs-lint.
The tool will recurse through every .nix file in the
provided path(,s).
$ nix build
$ ./result/bin/nixpkgs-lint <files or directories>
Why another linter? My motivation for this was spawned after doing a series of treewide PRs such as moving cmake to buildInputs. The strategy was similar each time; write some shell one-liner to go through every file (27,000+ of them) in Nixpkgs and find some anti-pattern to fix. However, this is quickly problematic for multiple reasons:
In general discussions on IRC and Matrix, a more AST-aware approach to linting was viewed favorably but not many people took it on, despite the availability of Nix parsers in various languages. I have some subjective reasons myself:
Often one or more of these would be pretty involved. Furthermore, it locks you into a specific parser (which may or may not have provided source information, parse all things correctly, etc.).
Enter tree-sitter. The Nix grammar for tree-sitter has been well-tested and tree-sitter having bindings in several languages gives you options in how to work with the resulting AST. You also get things like a location-annotated AST and error recovery for free.
This repository is licensed under the MIT license.
Rust
81.5%
Nix
15.8%
Shell
2.6%
A fast semantic linter for Nix using tree-sitter π³ + βοΈ. [maintainers=@Artturin,@siraben]
Rust
176
134 commits
updated Jun 22, 2026
This is a semantic linter for Nixpkgs that uses tree-sitter. Currently we have the following detections:
cmake, makeWrapper, pkg-config in buildInputsstdenv in nativeBuildInputsnixpkgs-lint can easily handle multi-line
expressions, eliminates false-positives from strings and comments
and gives exact spans for matchesTo use without installing, run nix run github:nix-community/nixpkgs-lint.
The tool will recurse through every .nix file in the
provided path(,s).
$ nix build
$ ./result/bin/nixpkgs-lint <files or directories>
Why another linter? My motivation for this was spawned after doing a series of treewide PRs such as moving cmake to buildInputs. The strategy was similar each time; write some shell one-liner to go through every file (27,000+ of them) in Nixpkgs and find some anti-pattern to fix. However, this is quickly problematic for multiple reasons:
In general discussions on IRC and Matrix, a more AST-aware approach to linting was viewed favorably but not many people took it on, despite the availability of Nix parsers in various languages. I have some subjective reasons myself:
Often one or more of these would be pretty involved. Furthermore, it locks you into a specific parser (which may or may not have provided source information, parse all things correctly, etc.).
Enter tree-sitter. The Nix grammar for tree-sitter has been well-tested and tree-sitter having bindings in several languages gives you options in how to work with the resulting AST. You also get things like a location-annotated AST and error recovery for free.
This repository is licensed under the MIT license.
Rust
81.5%
Nix
15.8%
Shell
2.6%