Files
second-brain/04-learning/guides/nixos/nix-flake-check-linters.md
T
kiskaadee 8a59b093b8
Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 8s
infra(validator): add DirectoryContract validation and migration manifest
2026-09-28 15:58:11 -05:00

1.7 KiB

type, project, tags
type project tags
guide nixos
nixos
flake
ci
linters
quality

Integrated Linters and Quality Checks in Nix Flake Check

Overview

Static analysis and linting checks are integrated directly into the Nix flake output (checks.x86_64-linux in flake.nix). This ensures that nix flake check verifies code hygiene and style alongside derivation evaluation.

Integrated Checks

  1. Python Linting (ruff-lint):

    • Tool: pkgs.ruff
    • Command: ruff check --no-cache ${self}
    • Enforces flake8, bugbear, and Python linting rules.
  2. Python Formatting Check (ruff-format):

    • Tool: pkgs.ruff
    • Command: ruff format --check ${self}
    • Verifies formatting consistency without mutating the source tree.
  3. Python Static Type Checking (pyright):

    • Tool: pkgs.pyright
    • Command: pyright ${self}
    • Analyzes type hints across Python scripts (e.g. bundle_project.py).
  4. Shell Script Linting (shellcheck):

    • Tool: pkgs.shellcheck
    • Command: find ${self} -type f -name "*.sh" -exec shellcheck -s bash {} +
    • Analyzes all .sh scripts in home/scripts/ and home/shell/.
    • Also added # shellcheck shell=bash directives to modular sourced scripts.

Developer Tooling Additions

  • Added shellcheck to home/dev.nix in home.packages so it is available interactively for editor diagnostics and CLI use.

Validation Commands

# Run all flake checks (linters + NixOS system evaluation)
nix flake check

# Run individual checks
nix build .#checks.x86_64-linux.ruff-lint --no-link
nix build .#checks.x86_64-linux.ruff-format --no-link
nix build .#checks.x86_64-linux.pyright --no-link
nix build .#checks.x86_64-linux.shellcheck --no-link