Tags

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.

Author: Nicholas Coltharp (mail@heraplem.xyz)

Last modified: 2026-06-17 Wed 17:47

Emacs 30.2 (Org mode 9.7.11)

Validate