Generating Cargo.nix via IFD
- ✅ 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.
There are two commands in the tools.nix
file:
generatedCargoNix
will generate a folder containing adefault.nix
, to be used as aCargo.nix
file. The argument it takes are:name
: required. The name of the project (need to be a valid nix name identifier, so no space are allowed, but dash are.)src
: required. The folder that contain the root of the Rust project.cargoToml
: optional. The name and path relative to thesrc
root of theCargo.toml
to use. Default toCargo.toml
.additionalCargoNixArgs
: optional, additional argument forcrate2nix
, in a list
appliedCargoNix
take the same argument thatgeneratedCargoNix
, but also call the generated file with thepkgs
provided when callingtools.nix
In a flake with flake-parts:
Without flakes, crate2nix
needs to point to the root of the crate2nix
sources:
Learn How it works.