Skip to content

ci: unify toolchain through the Nix flake#92

Merged
hakula139 merged 4 commits into
mainfrom
chore/pre-commit-hook
Jun 26, 2026
Merged

ci: unify toolchain through the Nix flake#92
hakula139 merged 4 commits into
mainfrom
chore/pre-commit-hook

Conversation

@hakula139

@hakula139 hakula139 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Make the Nix flake dev shell the single source of every tool. nix develop provisions the toolchain and installs a pre-commit hook; nix flake check runs the fast hooks; and every CI job runs through nix develop -c, so local and CI use the exact same toolchain. Replaces the dtolnay/rust-toolchain + standalone pnpm setup.

Design decisions

  • One toolchain source, multi-job CI. nix flake check runs only the compile-free hooks (rustfmt, nixfmt, markdownlint, cspell). Clippy, tests, and coverage stay as nix develop -c cargo ... jobs so Swatinem/rust-cache keeps incremental builds fast. Folding them into flake-check derivations would recompile the whole workspace every run with no cargo cache.
  • Hooks generated by git-hooks.nix, gitignored. The .pre-commit-config.yaml is generated from the flake and pinned through the lock; pnpm-based hooks no-op when node_modules is absent so the sandboxed nix flake check passes.
  • New setup-nix composite action + nix build job on Linux and macOS.
  • cargo-llvm-cov and llvm-tools-preview in the dev shell, so coverage runs via nix develop without a separate install action.
  • Pin nixpkgs to nixos-26.05 (rustc 1.95.0). The 26.05 alias of nixfmt-rfc-style to nixfmt is adopted to clear its deprecation warning.

Changes

File Description
flake.nix git-hooks-nix input, preCommitCheck, dev shell (toolchain + llvm-cov + node), checks.pre-commit, nixpkgs 26.05
flake.lock Lock git-hooks-nix and transitive inputs; nixpkgs 25.1126.05
.github/actions/setup-nix/action.yml Composite action: install Nix + Cachix
.github/workflows/ci.yml Run flake-check / rust-check / coverage / node-check / nix-build via nix develop -c
.gitignore Ignore generated .pre-commit-config.yaml and Nix artifacts
.cspell/words.txt Add cachix, direnv
CLAUDE.md Document nix develop / nix flake check under Verification
file_tracker.rs Order-independent assertion for restore_verified dropped paths (see note)

Notes

  • Incidental test fix. Building through the Nix sandbox surfaced a latent bug: restore_verified_returns_paths_of_dropped_snapshots asserted exact Vec order, but restore_verified builds that Vec from a HashMap (non-deterministic order). It passed by luck on the CI runner and failed under the sandbox's hash seed. Committed separately as test(file_tracker): ....

Test plan

All jobs validated locally through the flake:

  • nix flake check: all hooks pass
  • nix develop -c cargo fmt --all --check / clippy -D warnings / cargo test (2094 pass)
  • nix develop -c cargo llvm-cov ...: lcov generated
  • nix develop -c pnpm install / lint / spellcheck: 0 issues
  • nix build .#oxide-code: ox 0.1.0-alpha.2 binary produced
  • Real git commit exercises the installed hook

@hakula139 hakula139 self-assigned this Jun 25, 2026
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hakula139 hakula139 force-pushed the chore/pre-commit-hook branch from 1859498 to 1dc7059 Compare June 25, 2026 05:52
@hakula139 hakula139 changed the title chore: add opt-in pre-commit hook for fast CI checks chore(nix): add pre-commit hooks via git-hooks.nix Jun 25, 2026
restore_verified builds its dropped-paths Vec by iterating a HashMap, so
the order is non-deterministic. The exact-equality assertion passed by
luck on the CI runner but failed under a different hash seed (surfaced by
the sandboxed Nix build). Sort both sides before comparing; the dropped
order is not part of the function's contract.
Make the flake dev shell the single source of every tool, mirroring the
kiln repo. `nix develop` provisions the toolchain and installs a
pre-commit hook (rustfmt, nixfmt, markdownlint, cspell) via
git-hooks.nix; `nix flake check` runs the same hooks. CI now runs each
job through `nix develop -c`, replacing the dtolnay toolchain and the
standalone pnpm setup, and adds a `nix build` job on Linux and macOS.

Clippy, tests, and coverage stay as cargo invocations (with cargo
caching) rather than flake-check derivations, so incremental builds keep
working. The generated .pre-commit-config.yaml is gitignored.
@hakula139 hakula139 force-pushed the chore/pre-commit-hook branch from 1dc7059 to ce127c9 Compare June 25, 2026 10:50
@hakula139 hakula139 changed the title chore(nix): add pre-commit hooks via git-hooks.nix ci: unify toolchain through the Nix flake Jun 25, 2026
@hakula139 hakula139 added the enhancement New feature or request label Jun 26, 2026
Aliasing of nixfmt-rfc-style to nixfmt in 26.05 surfaces a deprecation warning; switch the hook to the canonical name.
@hakula139 hakula139 merged commit 0ea5353 into main Jun 26, 2026
7 checks passed
@hakula139 hakula139 deleted the chore/pre-commit-hook branch June 26, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant