Files
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

40 lines
1.1 KiB
Nix

# Dev shell built from the same craneLib/toolchain as the package build
# (nix/rust.nix), so the environment developers see locally matches what
# `nix build` uses as closely as possible.
{
pkgs,
lib,
rust,
}:
rust.craneLib.devShell {
inherit (rust) checks;
packages =
with pkgs;
[
cargo-nextest
cargo-criterion
cargo-audit
cargo-expand
taplo
bacon
just
]
++ lib.optionals pkgs.stdenv.isLinux [ mold ]
++ lib.optionals pkgs.stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
shellHook = ''
export RUST_SRC_PATH="${rust.rustToolchain}/lib/rustlib/src/rust/library"
''
+ lib.optionalString pkgs.stdenv.isLinux ''
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER="clang"
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="clang"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
'';
}