7,363 open-source and SaaS tools, with GitHub stats refreshed every day.

crate2nix

Open source

Tool that generates Nix build files from a Cargo project so each Rust crate is built separately, enabling incremental CI builds and caching with Nix.

nix-community.github.io
crate2nix homepage screenshot
GitHub stars
524
Last commit
2 days ago
Repository age
7 years
Version
0.15.0
Licence
Apache-2.0
Self-hosted
Yes

About crate2nix

crate2nix produces Nix build files for Rust projects that use Cargo. Rather than building a project as one unit, it creates a separate Nix derivation for each crate, so only the crates that changed need rebuilding. It is aimed at teams that use Nix and want finer-grained builds and caching for Rust code.

It reads Cargo.toml and Cargo.lock, resolves the dependency tree through cargo metadata, prefetches source hashes and renders a Cargo.nix file from templates. Generation can be manual, which avoids import-from-derivation and keeps full parallelism, or automatic, which stays in sync with the lockfile. An experimental JSON output moves feature resolution into Rust.

Day-to-day development is unchanged because you keep using cargo and rust-analyzer. On the Nix side it integrates with remote builds, binary caches, Docker images and NixOS modules, and tools.nix exposes helpers for your own expressions. It is maintained under the nix-community organization and licensed Apache-2.0.

Key features

  • Per-crate Nix derivations for incremental rebuilds
  • Generates Cargo.nix from Cargo.lock
  • Manual or import-from-derivation generation
  • Experimental JSON output format
  • Works with binary caches and remote builds
  • Nix helper functions via tools.nix

Good fit for

  • โ†’Speeding up Rust CI with Nix caching
  • โ†’Packaging Rust applications for NixOS
Built with
Nix
Rust
Tags
nix
rust
cargo
build-system
ci
nixos
caching

crate2nix: questions and answers

What is crate2nix used for?
crate2nix is a tool that generates Nix build files from a Cargo project so each Rust crate is built separately, enabling incremental CI builds and caching with Nix. It is a good fit for speeding up Rust CI with Nix caching and packaging Rust applications for NixOS.
Is crate2nix open source?
Yes. crate2nix is open source under the Apache-2.0 licence. Its source code is on GitHub at nix-community/crate2nix and is written mainly in Nix.
Is crate2nix free?
Yes. crate2nix is open source, so the software itself is free to use.
What are some alternatives to crate2nix?
Similar open-source tools in the Developer Tools category include Tach, Zed and Helix. SaaS products in the same category include RustRover, BuildBuddy and Develocity.
Is crate2nix actively maintained?
Yes. The most recent commit to crate2nix was on 30 September 2026, and the latest release is 0.15.0, published on 28 January 2026. The project has 524 stars on GitHub.

Open-source alternatives to crate2nix

See all

SaaS alternatives to crate2nix

See all