From 24d4479affca4421b89a8cb3845dfeff5062244b Mon Sep 17 00:00:00 2001 From: Brian Gyss Date: Thu, 29 Jan 2026 12:20:14 -0800 Subject: [PATCH 1/6] Add pre-commit and prek back pressure hooks --- .pre-commit-config.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ AGENTS.md | 9 +++++++++ README.md | 10 ++++++++++ docs/DEVELOPMENT.md | 23 +++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..915b705 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +default_stages: [pre-commit] +default_install_hook_types: [pre-commit, pre-push] + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-merge-conflict + - id: check-yaml + - id: check-toml + - id: check-json + - id: check-added-large-files + - id: detect-private-key + - id: check-executables-have-shebangs + - id: check-symlinks + - id: check-case-conflict + - repo: local + hooks: + - id: cargo-fmt + name: cargo fmt (check) + entry: cargo fmt --all -- --check + language: system + types: [rust] + pass_filenames: false + - id: cargo-clippy + name: cargo clippy (workspace) + entry: cargo clippy --workspace --all-targets --all-features -- -D warnings + language: system + pass_filenames: false + files: \.(rs|toml)$ + stages: [pre-push] + - id: cargo-test + name: cargo test (workspace) + entry: cargo test --workspace + language: system + pass_filenames: false + files: \.(rs|toml)$ + stages: [pre-push] diff --git a/AGENTS.md b/AGENTS.md index 881c118..97cfc4c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,6 +32,15 @@ SwitchRecomp is a preservation-focused static recompilation research project. Th - Test files live under `crates/*/tests/` or inline in modules. - Always run the full suite after changes unless the user explicitly says not to. +## Back Pressure Hooks +Pre-commit hooks provide fast feedback; `prek` is a drop-in replacement that reads the same `.pre-commit-config.yaml`. + +- Install hooks: `prek install` or `pre-commit install`. +- Run on demand: `prek run --all-files` or `pre-commit run --all-files`. +- Configured hooks: + - Pre-commit: `trailing-whitespace`, `end-of-file-fixer`, `check-merge-conflict`, `check-yaml`, `check-toml`, `check-json`, `check-added-large-files`, `detect-private-key`, `check-executables-have-shebangs`, `check-symlinks`, `check-case-conflict`, `cargo fmt --check`. + - Pre-push: `cargo clippy --workspace --all-targets --all-features -D warnings`, `cargo test --workspace`. + ## Commit & Pull Request Guidelines No established commit conventions are present yet. Until standards are set: - Use clear, imperative commit messages (e.g., "Add SPEC-070 OS services draft"). diff --git a/README.md b/README.md index d631b67..679b2d4 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,16 @@ This repository contains a draft specification set for a Nintendo Switch static - The dev environment is managed with Nix + devenv. - See `docs/DEVELOPMENT.md` for commands and sample usage. +## Back Pressure Hooks +These hooks add fast, consistent feedback to keep the repo autonomous and reduce review churn. Hooks are defined in `.pre-commit-config.yaml` and can be run with `prek` (preferred) or `pre-commit`. + +- Install hooks: `prek install` or `pre-commit install`. +- Run on demand: `prek run --all-files` or `pre-commit run --all-files`. + +Configured hooks: +- Pre-commit: `trailing-whitespace`, `end-of-file-fixer`, `check-merge-conflict`, `check-yaml`, `check-toml`, `check-json`, `check-added-large-files`, `detect-private-key`, `check-executables-have-shebangs`, `check-symlinks`, `check-case-conflict`, `cargo fmt --check`. +- Pre-push: `cargo clippy --workspace --all-targets --all-features -D warnings`, `cargo test --workspace`. + ## Specs Update Log - 2026-01-29: v0.2 pass started; added hardware baseline details, input/binary format research, OS/services surface notes, and timing/interrupts refinements across specs. - 2026-01-29: Added `SPEC-TEMPLATE.md` and expanded `RESEARCH.md` with seed sources. diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index f0f23b3..b1dec77 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -15,6 +15,29 @@ If you use direnv, run: direnv allow ``` +## Back Pressure Hooks (prek + pre-commit) +Back pressure keeps feedback close to the change. This repo uses pre-commit hooks for fast checks, and `prek` is a drop-in replacement that reads the same `.pre-commit-config.yaml`. + +Install hooks (config sets `default_install_hook_types` to `pre-commit` + `pre-push`): +``` +prek install +``` +``` +pre-commit install +``` + +Run hooks on demand: +``` +prek run --all-files +``` +``` +pre-commit run --all-files +``` + +Configured hooks: +- Pre-commit: `trailing-whitespace`, `end-of-file-fixer`, `check-merge-conflict`, `check-yaml`, `check-toml`, `check-json`, `check-added-large-files`, `detect-private-key`, `check-executables-have-shebangs`, `check-symlinks`, `check-case-conflict`, `cargo fmt --check`. +- Pre-push: `cargo clippy --workspace --all-targets --all-features -D warnings`, `cargo test --workspace`. + ## Workspace Commands - Run all tests: From 8019a29f3a0be58e7b0c3ba8c9539e0a6ca54478 Mon Sep 17 00:00:00 2001 From: Brian Gyss Date: Thu, 29 Jan 2026 13:49:48 -0800 Subject: [PATCH 2/6] Add prek and pre-commit to dev shell --- devenv.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devenv.nix b/devenv.nix index 1dca4d2..35d798e 100644 --- a/devenv.nix +++ b/devenv.nix @@ -3,6 +3,8 @@ packages = [ pkgs.cargo pkgs.clippy + pkgs.pre-commit + pkgs.prek pkgs.ripgrep pkgs.rustc pkgs.rustfmt From c5f199b9bdcedb24f3080e45be8c6f4b1be5c084 Mon Sep 17 00:00:00 2001 From: Brian Gyss Date: Thu, 29 Jan 2026 14:12:08 -0800 Subject: [PATCH 3/6] Update dev shell command for flake devenv --- AGENTS.md | 2 +- docs/DEVELOPMENT.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 97cfc4c..dc4603f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,7 +14,7 @@ SwitchRecomp is a preservation-focused static recompilation research project. Th - `README.md` is the project overview and contribution entry point. ## Build, Test, and Development Commands -- Dev shell: `devenv shell` +- Dev shell: `nix develop --impure` - Run all tests: `cargo test` - Run the sample pipeline: - `cargo run -p recomp-cli -- --module samples/minimal/module.json --config samples/minimal/title.toml --out-dir out/minimal` diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index b1dec77..5827b25 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -4,10 +4,10 @@ This project now includes an exploratory Rust workspace and uses Nix + devenv fo ## Nix + devenv - Install `nix` and `devenv`. -- Enter the shell from the repo root: +- This repo uses devenv's flake integration. Enter the shell from the repo root: ``` -devenv shell +nix develop --impure ``` If you use direnv, run: From 26f43a1031eb483b99e05b3ffdc1985a3ce3a818 Mon Sep 17 00:00:00 2001 From: Brian Gyss Date: Thu, 29 Jan 2026 15:45:38 -0800 Subject: [PATCH 4/6] Avoid pre-commit in darwin dev shell --- AGENTS.md | 1 + README.md | 1 + devenv.nix | 3 ++- docs/DEVELOPMENT.md | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index dc4603f..85b30bd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -37,6 +37,7 @@ Pre-commit hooks provide fast feedback; `prek` is a drop-in replacement that rea - Install hooks: `prek install` or `pre-commit install`. - Run on demand: `prek run --all-files` or `pre-commit run --all-files`. +- macOS note: the Nix dev shell ships `prek` only (to avoid Swift/.NET builds); install `pre-commit` separately if you need it. - Configured hooks: - Pre-commit: `trailing-whitespace`, `end-of-file-fixer`, `check-merge-conflict`, `check-yaml`, `check-toml`, `check-json`, `check-added-large-files`, `detect-private-key`, `check-executables-have-shebangs`, `check-symlinks`, `check-case-conflict`, `cargo fmt --check`. - Pre-push: `cargo clippy --workspace --all-targets --all-features -D warnings`, `cargo test --workspace`. diff --git a/README.md b/README.md index 679b2d4..30b9066 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ These hooks add fast, consistent feedback to keep the repo autonomous and reduce - Install hooks: `prek install` or `pre-commit install`. - Run on demand: `prek run --all-files` or `pre-commit run --all-files`. +- macOS note: the Nix dev shell ships `prek` only (to avoid Swift/.NET builds); install `pre-commit` separately if you need it. Configured hooks: - Pre-commit: `trailing-whitespace`, `end-of-file-fixer`, `check-merge-conflict`, `check-yaml`, `check-toml`, `check-json`, `check-added-large-files`, `detect-private-key`, `check-executables-have-shebangs`, `check-symlinks`, `check-case-conflict`, `cargo fmt --check`. diff --git a/devenv.nix b/devenv.nix index 35d798e..180ac69 100644 --- a/devenv.nix +++ b/devenv.nix @@ -3,11 +3,12 @@ packages = [ pkgs.cargo pkgs.clippy - pkgs.pre-commit pkgs.prek pkgs.ripgrep pkgs.rustc pkgs.rustfmt + ] ++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [ + pkgs.pre-commit ]; cachix.enable = false; diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 5827b25..940237d 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -34,6 +34,8 @@ prek run --all-files pre-commit run --all-files ``` +macOS note: the Nix dev shell ships `prek` only (to avoid Swift/.NET builds); install `pre-commit` separately if you need it. + Configured hooks: - Pre-commit: `trailing-whitespace`, `end-of-file-fixer`, `check-merge-conflict`, `check-yaml`, `check-toml`, `check-json`, `check-added-large-files`, `detect-private-key`, `check-executables-have-shebangs`, `check-symlinks`, `check-case-conflict`, `cargo fmt --check`. - Pre-push: `cargo clippy --workspace --all-targets --all-features -D warnings`, `cargo test --workspace`. From ca535bb263b85245b812fc25433037cd3d6e2a24 Mon Sep 17 00:00:00 2001 From: Brian Gyss Date: Thu, 29 Jan 2026 16:05:09 -0800 Subject: [PATCH 5/6] Watch devenv.nix for direnv reloads --- .envrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.envrc b/.envrc index cffc922..b025138 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,2 @@ +watch_file devenv.nix use flake . --impure From 0638233b54fe5abcc0578c1261c0e9fe59a11098 Mon Sep 17 00:00:00 2001 From: Brian Gyss Date: Thu, 29 Jan 2026 16:20:30 -0800 Subject: [PATCH 6/6] Document direnv reload after devenv changes --- docs/DEVELOPMENT.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 940237d..df327a1 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -15,6 +15,8 @@ If you use direnv, run: direnv allow ``` +If `devenv.nix` changes, run `direnv reload` so nix-direnv refreshes the cached shell. + ## Back Pressure Hooks (prek + pre-commit) Back pressure keeps feedback close to the change. This repo uses pre-commit hooks for fast checks, and `prek` is a drop-in replacement that reads the same `.pre-commit-config.yaml`.