What is crate2nix?
mastercrate2nix is a tool that builds Rust projects crate-by-crate using Nix. It leverages cargo_metadata to ensure the dependency tree and versions exactly match your Cargo.lock file.
Key benefits include:
- Hermetic CI builds: Only rebuild changed crates to save time.
- Smart Caching: Caches individual crate builds to minimize Nix rebuilds.
- Native Dependency Support: Uses the NixOS
buildRustCratefunction to handle libraries with non-Rust dependencies. - Nix Ecosystem Integration: Compatible with remote builds, minimal Docker images, and cloud deployments.
- Flexible Nix Generation: Can optionally generate
Cargo.nixduring evaluation time so it doesn't need to be committed to version control.