build a Rust package in Nix
If you have a pre-existing Rust package that you just need to build really quickly via Nix, this is the simplest thing to do.
# package.nix
{ rustPlatform }: rustPlatform.buildRustPackage {
name = "rust-example";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
# ...
}
If you need native libraries, you can put them in buildInputs. In that case, you'll probably also need to put pkg-config in nativeBuildInputs.