{"id":13648559,"url":"https://github.com/astro/deadnix","last_synced_at":"2025-05-14T17:03:49.544Z","repository":{"id":37958270,"uuid":"435300487","full_name":"astro/deadnix","owner":"astro","description":"Scan Nix files for dead code","archived":false,"fork":false,"pushed_at":"2025-05-11T01:36:58.000Z","size":220,"stargazers_count":581,"open_issues_count":7,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-14T17:01:58.570Z","etag":null,"topics":["nix","nix-flake","nix-lang","nixos","rnix","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["astro"]}},"created_at":"2021-12-05T23:06:43.000Z","updated_at":"2025-05-07T14:24:04.000Z","dependencies_parsed_at":"2023-10-29T01:32:08.187Z","dependency_job_id":"ec042561-eadf-4d79-97d7-5d4fd3b721c7","html_url":"https://github.com/astro/deadnix","commit_stats":{"total_commits":218,"total_committers":14,"mean_commits":"15.571428571428571","dds":0.3119266055045872,"last_synced_commit":"b341adb745fd29075869a52161ae0097ceb7d3a6"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fdeadnix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fdeadnix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fdeadnix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fdeadnix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astro","download_url":"https://codeload.github.com/astro/deadnix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254190379,"owners_count":22029632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nix","nix-flake","nix-lang","nixos","rnix","rust"],"created_at":"2024-08-02T01:04:20.905Z","updated_at":"2025-05-14T17:03:49.494Z","avatar_url":"https://github.com/astro.png","language":"Rust","readme":"# deadnix\n\nScan `.nix` files for dead code (unused variable bindings).\n\n## Usage with Github Actions\n\nSee [deadnix-action](https://github.com/astro/deadnix-action)\n\n\n## Usage with Nix Flakes\n\n### Help\n\n```console\nnix run github:astro/deadnix -- --help\nFind dead code in .nix files\n\nUsage: deadnix [OPTIONS] [FILE_PATHS]...\n\nArguments:\n  [FILE_PATHS]...  .nix files, or directories with .nix files inside [default: .]\n\nOptions:\n  -l, --no-lambda-arg                  Don't check lambda parameter arguments\n  -L, --no-lambda-pattern-names        Don't check lambda attrset pattern names (don't break nixpkgs callPackage)\n  -_, --no-underscore                  Don't check any bindings that start with a _\n  -q, --quiet                          Don't print dead code report\n  -e, --edit                           Remove unused code and write to source file\n  -h, --hidden                         Recurse into hidden subdirectories and process hidden .*.nix files\n      --help\n  -f, --fail                           Exit with 1 if unused code has been found\n  -o, --output-format \u003cOUTPUT_FORMAT\u003e  Output format to use [default: human-readable] [possible values: human-readable, json]\n      --exclude \u003cEXCLUDES\u003e...          Files to exclude from analysis\n  -V, --version                        Print version\n```\n\nReports contain ANSI color escape codes unless the\n[`$NO_COLOR`](https://no-color.org/) environment variable is set.\n\nThe `--exclude` parameter accepts multiple paths. Separate them with\n`--` to pass `[FILE_PATHS]...`.\n\n### Scan for unused code\n\n```console\nnix run github:astro/deadnix example.nix\nWarning: Unused declarations were found.\n    ╭─[example.nix:1:1]\n  1 │unusedArgs@{ unusedArg, usedArg, ... }:\n    ·     │           ╰───── Unused lambda pattern: unusedArg\n    ·     ╰───────────────── Unused lambda pattern: unusedArgs\n  3 │  inherit (builtins) unused_inherit;\n    ·                            ╰─────── Unused let binding: unused_inherit\n  5 │  unused = \"fnord\";\n    ·     ╰─── Unused let binding: unused\n 10 │  shadowed = 42;\n    ·      ╰──── Unused let binding: shadowed\n 11 │  _unused = unused: false;\n    ·     │         ╰─── Unused lambda argument: unused\n    ·     ╰───────────── Unused let binding: _unused\n 13 │  x = { unusedArg2, x ? args.y, ... }@args: used1 + x;\n    ·             ╰───── Unused lambda pattern: unusedArg2\n```\n\n\n### Remove unused code automatically\n\n**Do commit** your changes into version control **before!**\n\n```console\nnix run github:astro/deadnix -- -eq test.nix\n```\n\n## Usage with [pre-commit](https://pre-commit.com/)\n\nAdd the following to your project's `.pre-commit-config.yaml`:\n```yaml\nrepos:\n  - repo: https://github.com/astro/deadnix\n    rev: ID # frozen: VERSION\n    hooks:\n      - id: deadnix\n        #args: [--edit] # Uncomment to automatically modify files\n        stages: [commit]\n```\n\nReplace `ID` and `VERSION` above with the relevant version tag and\ncommit ID for reference, for example:\n\n```yaml\nrev: da39a3ee5e6b4b0d3255bfef95601890afd80709  # frozen: v1.2.3\n```\n\n## Behavior\n\n### Renaming of all unused to lambda args to start with `_`\n\nIf you disfavor marking them as unused, use option\n`-l`/`--no-lambda-arg`.\n\n\n### nixpkgs `callPackages` with multiple imports\n\n`callPackages` guesses the packages to inject by the names of a\npackages' lambda attrset pattern names. Some packages alias these with\n`@args` to pass them to another `import ...nix args`.\n\nAs the used args are only named in the imported file they will be\nrecognized as dead in the package source file that is imported by\n`callPackage`, rendering it unable to guess the dependencies to call\nthe packages with.\n\nUse option `-L`/`--no-lambda-pattern-names` in this case.\n\n\n### Skipping reports for certain declarations\n\nAs of 1.1.0 deadnix supports the following pragma to skip check of\nbindings in the following line:\n\n```nix\n# deadnix: skip\n```\n\n\n## What if the produced reports are wrong?\n\nPlease open an issue. Do not forget to include the `.nix` code that\nproduces incorrect results.\n\n\n## Commercial Support\n\nThe author can be hired to implement the features that you wish, or to\nintegrate this tool into your toolchain.\n","funding_links":["https://github.com/sponsors/astro"],"categories":["Rust","Command-Line Tools","Other"],"sub_categories":["Discovery"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fdeadnix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastro%2Fdeadnix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fdeadnix/lists"}