Files
second-brain/projects/nixos/guides/nix-flake-check-linters.md
T
kiskaadee ed2d9b997c
Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 11s
docs(nixos): add terminal workspace guide, flake linters guide, and DMS reproducibility plan
Curate workstation subsystem guides covering Niri/Alacritty/Tmux navigation,
Nix flake check linters, and the DMS operational reproducibility plan.
2026-09-15 21:43:39 -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