Fix formatting drift after rename, and document git-init requirement

Found via an end-to-end test of nix flake init -> rename -> nix flake
check: renaming can reorder `use` statements alphabetically (e.g.
"acme_widget" now sorts before "criterion"), and treefmt's rustfmt
(nixpkgs) disagreed with cargo fmt's rustfmt (fenix toolchain) on
edition-2024 import grouping, so the formatting check failed right
after a clean rename.

- nix/treefmt.nix: pin programs.rustfmt.edition = "2024" to match
  Cargo.toml, so treefmt and cargo fmt agree.
- scripts/rename-project.sh: auto-format (cargo fmt, falling back to
  nix fmt) after renaming, and note that nix commands need git-tracked
  files.
- README.md/CLAUDE.md: document that `nix flake init -t` doesn't
  git-init for you, and every nix command needs `git add` first.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
This commit is contained in:
2026-08-11 01:06:58 +08:00
parent c7303154cc
commit f07e0c08c8
4 changed files with 33 additions and 6 deletions
+6 -3
View File
@@ -6,13 +6,16 @@ way with plain `cargo` or with `nix`.
## Using this template
1. Copy/clone this repo (or, once published, `nix flake init -t <this-repo-url>`).
2. Rename the placeholder crate name:
1. Copy/clone this repo, or scaffold fresh with `nix flake init -t <this-repo-url>`.
2. If you used `nix flake init` (no `.git` yet), run `git init && git add -A`
Nix flakes only see git-tracked files, so every `nix` command below needs this first.
3. Rename the placeholder crate name:
```bash
./scripts/rename-project.sh my_project
cd .. && mv rust_template my_project && cd my_project
git add -A # stage the rename before running any nix command again
```
3. Build whatever you actually came here for — replace `greet` in `src/lib.rs`, extend the CLI in
4. Build whatever you actually came here for — replace `greet` in `src/lib.rs`, extend the CLI in
`src/main.rs`, add your own tests and benchmarks.
## Building and running