Align dev-shell rustfmt with craneLib's cargo-fmt check #12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Surfaced when CI rejected formatting that local
cargo fmt --all -- --checkaccepted (commitfb19499→ CI run 19 → rustfmt diff incrates/ar-prompts/src/schema.rsandcrates/ar-index/src/embed.rs).The dev-shell and the flake check resolve to different rustfmt store paths, despite
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchainin flake.nix:/nix/store/.../rustfmt-preview-1.97.0-nightly-2026-05-01/bin/rustfmt/nix/store/.../rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz.drv(different package, same toolchain version)Same toolchain version but different packages (
rustfmt-previewfrom the rust-overlay bundle vsrustfmt-nightlyfrom craneLib's own resolution). They diverge in formatting decisions. Result: a developer who runscargo fmt --all -- --checklocally and sees no diff still gets red CI.User directive: whichever is stricter wins; the two should match.
Proposed fix: ensure
craneLib.cargoFmtuses the same rustfmt binary the dev shell does. Either:rustfmtderivation tocraneLib.cargoFmtso it's pinned to the same one in the dev shell, orscripts/fmt-checkthat invokesnix flake check .#cargo-fmt(the CI command) and document it as the only fmt gate; removecargo fmt --all -- --checkfrom contributor docs.(2) is the lower-effort fix; (1) is the right fix because (2) requires every contributor to remember the special command.
Touches:
flake.nix(around line 160 — thecraneLib.cargoFmtinvocation).