Rust Project via Flake Template
- *️⃣ Uses nix flakes.
- ✅ No need to install
crate2nix
. - ✅ Auto-generates nix from your
Cargo.lock
file. - ⚠️ Uses the import from derivation feature from Nix which may lead to disabling build parallelism.
- ✅ Uses an overlay to use the rust version specified in
rust-toolchain.toml
.
Call this in your project directory:
If the directory is empty, it will also create a hello world stub.
If you call this from an existing project, make sure to delete any superfluous
files. The template expects top-level Cargo.toml
/Cargo.lock
files,
and a single result binary, otherwise you need to adjust flake.nix
manually.
Continue to use cargo
/rust-analyzer
for a fast developer loop and use
nix to verify your program hermetically with nix locally and in CI: