Open Tanvir1337x opened 5 months ago
Add the following to your project's .pre-commit-config.yaml
:
- repo: https://github.com/astro/deadnix
rev: v1.2.1 # Replace with the relevant version tag/commit ID
hooks:
- id: deadnix
args: [--edit] # Automatically modify files
stages: [commit]
Add the following to your project's .github/workflows/deadnix.yml
:
name: Dead nix code analysis
on:
push:
paths:
- "**.nix"
workflow_dispatch:
jobs:
deadnix:
name: Deadnix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
- uses: cachix/cachix-action@v14
with:
name: deadnix
- uses: astro/deadnix-action@main
The workflow runs automatically on every push to the repository that includes changes to .nix files.
It can also be triggered manually via the "Workflow dispatch" feature in the GitHub Actions tab of the repository. It provides flexibility to run the formatting process as needed outside of the regular push events.
Possible to apply fixes with deadnix -e
and push it with something like:
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: fixing dead code issues with deadnix"
or for PR/MR we could use something like peter-evans/create-pull-request
.
I'm using this workflow: deadnix.yml
ref: deadnix See
deadnix --help
for a full list of options.To highlight the dead codes in your nix code:
It recursively finds nix files and raises dead code issues for the provided directory.
To fix several such occurrences: