nix-validation

Validates Nix code using treefmt-nix, statix, deadnix, and flake checks.

1|Updated Aug 21, 2023
One-click install
npx skills add https://github.com/jmuchovej/homelab --skill nix-validation-jmuchovej
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nix-validation
Source: https://github.com/jmuchovej/homelab/tree/main/src/modules/ai-tools/skills/nix-validation
Command: npx skills add https://github.com/jmuchovej/homelab --skill nix-validation-jmuchovej

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Nix codebases accumulate syntax errors, anti-patterns, and unused bindings that are hard to catch manually, and configuring a consistent linting and formatting pipeline across a flake is tedious and error-prone. ## Core Features & Use Cases - Unified formatting and linting: Configure treefmt-nix to combine nixfmt, statix, and deadnix into a single formatter and flake check. - Anti-pattern detection: Identify and auto-fix common Nix issues like bool comparisons, eta reduction, manual inherit, and legacy let syntax with statix. - Dead code removal: Find and remove unused bindings with deadnix while avoiding common false positives like self in flake outputs. - Use Case: Before committing changes to a NixOS or home-manager flake, run nix fmt and nix flake check to verify formatting, lint rules, and module evaluation all pass. ## Quick Start Ask the assistant to set up treefmt-nix with nixfmt, statix, and deadnix in your flake and validate all Nix files in the repository.

Frequently Asked Questions about nix-validation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I lint Nix files with statix and deadnix?

Run `statix check .` to detect anti-patterns like bool comparisons and manual inherit, and `deadnix .` to find unused bindings. Use `statix fix .` and `deadnix -e .` to auto-apply fixes across the project.

How to set up treefmt-nix in a Nix flake?

Add treefmt-nix as a flake input, evaluate its module with `treefmt-nix.lib.evalModule`, and enable nixfmt, deadnix, and statix under `programs`. Expose the wrapper as `formatter` and the check under `checks`.

What is the difference between statix and deadnix?

statix detects anti-patterns such as eta reduction, empty let-in, and unquoted URIs, while deadnix finds unused code like unreferenced let bindings and lambda arguments. They complement each other and are commonly run together via treefmt-nix.

Why does deadnix report false positives on flake outputs?

deadnix flags `self` in flake outputs and module arguments used only in imports as unused. Hide `self` with a `...` pattern, prefix intentionally unused variables with `_`, or use flags like `--no-lambda-arg` to reduce noise.

How do I check Nix syntax without full evaluation?

Run `nix-instantiate --parse file.nix` for an instant syntax-only check without evaluation. For full evaluation including all checks, use `nix flake check`, which is slower but thorough.

How do I add a pre-commit hook for Nix formatting?

Define a devShell with nixfmt, statix, and deadnix, then install a git pre-commit hook that runs these tools on staged `.nix` files. Alternatively, integrate pre-commit-hooks.nix as a flake check.