百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

statix

> 开发工具
开源

nix 编程语言的错误检查和建议

935 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

nix 编程语言的错误检查和建议

[!CAUTION]

  1. This project is now hosted at tangled.
  2. A significant fork by Molybdenum Software exists.
  3. The source for the Nixpkgs statix package is the Molybdenum Software fork
  4. The maintainer of the Molybdenum Software fork is eager to merge back.

statix

Lints and suggestions for the Nix programming language.

statix check highlights antipatterns in Nix code. statix fix can fix several such occurrences.

For the time-being, statix works only with ASTs produced by the rnix-parser crate and does not evaluate any nix code (imports, attr sets etc.).

Examples

bash
$ statix check tests/c.nix
[W04] Warning: Assignment instead of inherit from
   ╭─[tests/c.nix:2:3]
   │
 2 │   mtl = pkgs.haskellPackages.mtl;
   ·   ───────────────┬───────────────
   ·                  ╰───────────────── This assignment is better written with inherit
───╯

$ statix fix --dry-run tests/c.nix
--- tests/c.nix
+++ tests/c.nix [fixed]
@@ -1,6 +1,6 @@
 let
-  mtl = pkgs.haskellPackages.mtl;
+  inherit (pkgs.haskellPackages) mtl;
 in
 null

Installation

statix is available via a nix flake:

bash
# build from source
nix build git+https://git.peppe.rs/languages/statix
./result/bin/statix --help

# statix also provides a flake app
nix run git+https://git.peppe.rs/languages/statix -- --help

# save time on builds using cachix
cachix use statix

Install from nixpkgs:

bash
nix run nixpkgs#statix -- help

Install with brew/linuxbrew

bash
brew install statix

Usage

Basic usage is as simple as:

bash
# recursively finds nix files and raises lints
statix check /path/to/dir

# ignore generated files, such as Cargo.nix
statix check /path/to/dir -i Cargo.nix

# ignore more than one file
statix check /path/to/dir -i a.nix b.nix c.nix

# ignore an entire directory
statix check /path/to/dir -i .direnv

# statix respects your .gitignore if it exists
# run statix in "unrestricted" mode, to disable that
statix check /path/to/dir -u

# see `statix -h` for a full list of options

Certain lints have suggestions. Apply suggestions back to the source with:

bash
statix fix /path/to/file

# show diff, do not write to file
statix fix --dry-run /path/to/file

statix supports a variety of output formats; standard, json and errfmt:

bash
statix check /path/to/dir -o json   # only when compiled with --all-features
statix check /path/to/dir -o errfmt # singleline, easy to integrate with vim

Configuration

Ignore lints and fixes by creating a statix.toml file at your project root:

# within statix.toml
disabled = [
  "empty_pattern"
]

statix automatically discovers the configuration file by traversing parents of the current directory and looking for a statix.toml file. Alternatively, you can pass the path to the statix.toml file on the command line with the --config flag (available on statix check and statix fix).

The available lints are (see statix list for an updated list):

bool_comparison
empty_let_in
manual_inherit
manual_inherit_from
legacy_let_syntax
collapsible_let_in
eta_reduction
useless_parens
empty_pattern
redundant_pattern_bind
unquoted_uri
empty_inherit
deprecated_to_path
bool_simplification
useless_has_attr

All lints are enabled by default. Generate a minimal config with statix dump > statix.toml.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustlinternix

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具