Open TanvirOnGH opened 1 week ago
Add the following to your project's .github/workflows/statix.yml
:
name: Lint with statix
on:
push:
paths:
- "**.nix"
workflow_dispatch:
jobs:
statix:
name: Lint code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
- uses: cachix/cachix-action@v14
with:
name: statix
- uses: jocelynthode/statix-action@master
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 statix fix
and push it with something like:
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: linting nix code with deadnix"
or for PR/MR we could use something like peter-evans/create-pull-request
.
I'm using this workflow: statix.yml
ref: statix See
statix -h
for a full list of options. Can be configured withstatix.toml
per project. All lints are enabled by default. To generate a minimal config:To highlight the anti-patterns in your nix code:
It recursively finds nix files and raises lints for the provided directory.
To fix several such occurrences: