7 Commits

Author SHA1 Message Date
tomatocream f07e0c08c8 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
2026-08-11 01:06:58 +08:00
tomatocream c7303154cc Add flake.templates, justfile, and .envrc for direnv
Compared this template against the older nix-templates/templates/rust
("rrrr") ahead of eventually replacing it. Ported the pieces that were
genuinely missing and non-controversial:

- flake.templates.default, so `nix flake init -t <url>` works once
  this repo is published — the actual mechanism a "template" needs.
- justfile wrapping the cargo/nix commands for discoverability.
- .envrc (use flake) for direnv auto-activation.
- `just` added to the dev shell so the justfile is usable without a
  separate install.

Left out on purpose: workspace crate split, tracing/serde/tokio-heavy
example code, docker.nix, nightly coverage toolchain, and copier.yaml —
those make it an opinionated async-service starter rather than a blank
Rust template, and copier.yaml in the old repo was dead configuration
(no file actually referenced its Jinja variables).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
2026-08-11 00:50:51 +08:00
tomatocream d61ba8aec2 Add README.md and make the template workflow explicit in CLAUDE.md
README covers the copy-clone-rename-build flow and the simple cargo/nix
run commands. CLAUDE.md now states the intended workflow up front
(rename script, then build whatever the user actually wants) instead
of only implying it via the rename-script section.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
2026-08-11 00:28:57 +08:00
tomatocream 6e460aca80 Add CLAUDE.md documenting cargo/nix workflows and architecture
Covers both dev paths (plain cargo vs nix develop/build/flake check),
LSP setup via the fenix toolchain's RUST_SRC_PATH, how nix/rust.nix
is shared between the package build and dev shell, where to add
unit vs integration tests, and how to use the rename script. Includes
a note to keep it updated as the template grows into real functionality.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
2026-08-11 00:22:30 +08:00
tomatocream 2583848813 Add integration test example and project rename script
tests/greet.rs shows the tests/ convention alongside the existing
inline unit test in src/lib.rs, so both standard locations are covered.

scripts/rename-project.sh replaces the "rust_template" placeholder
throughout Cargo.toml, flake.nix, nix/rust.nix, src/main.rs,
benches/greet.rs, and tests/greet.rs, then regenerates Cargo.lock.
Verified in a scratch copy: renamed crate builds, tests pass, and the
Nix package builds and runs correctly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
2026-08-11 00:16:55 +08:00
tomatocream 840cea1f10 Add Nix flake: crane + fenix build, treefmt-nix formatting
Uses flake-parts to organize outputs, with nix/rust.nix defining a
single craneLib/toolchain/commonArgs environment shared by the package
build (nix/rust.nix) and the dev shell (nix/devshell.nix), so both stay
close to identical. Deps are cached separately from the crate itself via
crane's buildDepsOnly, giving incremental rebuilds. Checks cover clippy,
rustfmt, cargo-doc, cargo-audit, and nextest; treefmt-nix wires up
`nix fmt` for Rust/Nix/TOML files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
2026-08-10 23:58:00 +08:00
tomatocream 979e77571f Add clap CLI, lib crate, unit test, and criterion benchmark
Minimal scaffold before turning this into a Nix flake template.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ALEXkc7pTro7tF1WcUuKb
2026-08-10 23:49:06 +08:00