| name | nix-review |
| description | Reviews and improves .nix files to make them truly superb. Use when the user wants to review, audit, improve, or fix Nix files — including flake.nix, NixOS modules, overlays, devShells, packages, or any .nix file. Also trigger when the user asks about nix quality, nix anti-patterns, nix best practices, wants to make their flakes excellent, or says "nix review", "review nix", "review .nix", "improve flake". Covers build correctness, security hardening, reproducibility, module design, source filtering, overlay architecture, performance, systemd hardening, and common pitfalls. |
| metadata | {"tags":"nix, flakes, review, quality, best-practices, nixos, modules, overlays, systemd, performance"} |
Nix Review
A comprehensive review skill for making .nix files truly superb. Based on analysis of 126+ real .nix files across production codebases (systematically standardized in 3 sessions) and community best practices from nix.dev, NixOS Wiki, Nixcademy, flake-parts docs, and systemd hardening guides.
Process
READ, UNDERSTAND, RESEARCH, REFLECT before each action.
Step 1: Discovery
Find all .nix files in the target scope:
find . -name "*.nix" -type f | head -50
Read every file. Do not skip any. Understanding the full picture is essential for catching cross-cutting issues like overlay duplication, inconsistent patterns, and import cycles.
Step 2: Categorize
Classify each file into its role:
| Category | Examples |
|---|
| Flake entry | flake.nix |
| Package definitions | pkgs/*.nix, package.nix |
| NixOS modules | modules/**/*.nix |
| Home Manager | home.nix, programs/*.nix |
| Library functions | lib/*.nix |
| Dev shells | devShells sections |
| Tests/Checks | checks sections, tests/*.nix |
| Templates | templates/*/flake.nix |
Step 3: Review Against Checklist
For each file, check ALL categories below. Read references/common-problems.md for detailed explanations and fixes of each issue.
Critical (Build Breakers)
Purity & Reproducibility
Structural
Correctness
Consistency
NixOS Modules (if applicable)
Security
Performance
DevShells (if applicable)
Overlays (if applicable)
Step 4: Generate Report
Produce a structured report with these sections:
# Nix Review Report
## Executive Summary
- X files reviewed
- Y critical issues (build breakers)
- Z structural issues
- W consistency issues
## Critical Issues (Must Fix)
| # | File | Line | Issue | Fix |
| --- | --------- | ---- | ---------------------- | ------------------------ |
| 1 | flake.nix | 42 | Placeholder vendorHash | Replace with actual hash |
## Structural Issues (Should Fix)
| # | File | Issue | Recommendation |
| --- | ----------- | --------- | -------------------------------------- |
| 1 | service.nix | 550 lines | Split into server/repos/runner modules |
## Consistency Issues
| # | Files | Issue | Fix |
| --- | -------- | ----------------- | ----------------------------- |
| 1 | 3 flakes | Formatter missing | Add `formatter = pkgs.nixfmt` |
## Best Practice Violations
| # | File | Violation | Better Approach |
| --- | ---- | --------- | --------------- |
## Strengths (What's Done Well)
- Good use of X pattern
- Clean Y structure
Step 5: Fix (When Requested)
When the user asks to fix issues:
- Fix critical issues first (build breakers)
- Fix structural issues (duplicated hashes, monoliths)
- Fix consistency issues (formatters, channels)
- Fix best practice violations
After each fix, verify:
nix flake check passes (or nix build for package flakes)
nix fmt -- --check passes (if formatter defined)
- No regressions in other files
Key Principles
The reason for each check matters more than the check itself. A review that explains "why" is far more valuable than one that just says "fix this." When reporting issues, always include:
- What the issue is
- Why it matters (performance, correctness, security, maintainability)
- How to fix it (concrete code example)
Severity Guide
| Severity | Meaning |
|---|
| 🔴 Critical | Won't build, security vulnerability, data loss risk |
| 🟠 High | Wrong behavior, impurity, non-reproducible |
| 🟡 Medium | Maintainability, consistency, structural debt |
| 🔵 Low | Style, naming, minor improvements |
References
references/common-problems.md — Detailed catalogue of 50 common problems with fixes, organized by category
references/best-practices.md — Ideal patterns for flake structure, modules, overlays, source filtering, systemd hardening, devShells, and performance
Read these files when you need specific examples or deeper guidance on a particular issue category.
Execution
READ, UNDERSTAND, RESEARCH, REFLECT.
Break this down into multiple actionable steps. Think about them again.
Execute and Verify them one step at the time.
Repeat until done. Keep going until everything works and you think you did a great job!