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
This commit is contained in:
2026-08-11 00:50:51 +08:00
parent d61ba8aec2
commit c7303154cc
6 changed files with 100 additions and 2 deletions
+71
View File
@@ -0,0 +1,71 @@
# justfile — task runner. See: https://just.systems/
# Available via `nix develop` (or install `just` yourself).
default:
@just --list
# --- cargo ---
build:
cargo build
build-release:
cargo build --release
run *args:
cargo run -- {{ args }}
test:
cargo test
bench:
cargo bench
clippy:
cargo clippy --all-targets -- --deny warnings
fmt:
nix fmt
fmt-check:
nix fmt -- --fail-on-change
audit:
cargo audit
doc:
cargo doc --no-deps
doc-open:
cargo doc --no-deps --open
# Everything nix flake check runs, but via cargo for a faster local loop
ci: fmt-check clippy test audit doc
clean:
cargo clean
rm -rf result result-*
# Background code checker (bacon)
watch:
bacon
# --- nix ---
nix-build:
nix build
nix-check:
nix flake check
nix-develop:
nix develop
nix-update:
nix flake update
# --- template ---
# Rename the "rust_template" placeholder to <name> (snake_case)
rename name:
./scripts/rename-project.sh {{ name }}