Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

deadnix

> 编程语言
Open source

Scan Nix files for dead code

773 stars0 likes1 views
WebsiteGitHub

About

Scan Nix files for dead code

deadnix

Scan .nix files for dead code (unused variable bindings).

Usage with Github Actions

See deadnix-action

Usage with Nix Flakes

Help

…

Reports contain ANSI color escape codes unless the $NO_COLOR environment variable is set.

The --exclude parameter accepts multiple paths. Separate them with -- to pass [FILE_PATHS]....

Scan for unused code

…

Remove unused code automatically

Do commit your changes into version control before!

bash
nix run github:astro/deadnix -- -eq test.nix

Usage with pre-commit

Add the following to your project's .pre-commit-config.yaml:

yaml
repos:
  - repo: https://github.com/astro/deadnix
    rev: ID # frozen: VERSION
    hooks:
      - id: deadnix
        #args: [--edit] # Uncomment to automatically modify files
        stages: [commit]

Replace ID and VERSION above with the relevant version tag and commit ID for reference, for example:

yaml
rev: da39a3ee5e6b4b0d3255bfef95601890afd80709  # frozen: v1.2.3

Behavior

Renaming of all unused to lambda args to start with _

If you disfavor marking them as unused, use option -l/--no-lambda-arg.

nixpkgs callPackages with multiple imports

callPackages guesses the packages to inject by the names of a packages' lambda attrset pattern names. Some packages alias these with @args to pass them to another import ...nix args.

As the used args are only named in the imported file they will be recognized as dead in the package source file that is imported by callPackage, rendering it unable to guess the dependencies to call the packages with.

Use option -L/--no-lambda-pattern-names in this case.

Skipping reports for certain declarations

As of 1.1.0 deadnix supports the following pragma to skip check of bindings in the following line:

nix
# deadnix: skip

What if the produced reports are wrong?

Please open an issue. Do not forget to include the .nix code that produces incorrect results.

Commercial Support

The author can be hired to implement the features that you wish, or to integrate this tool into your toolchain.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustnixnix-flakenix-langnixos

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言