Generate Nix expressions from Rust Cargo projects for granular, reproducible builds and development environments.
cargo2nix is a tool that generates Nix expressions from Rust Cargo projects, enabling them to be built and managed within the Nix ecosystem. It solves the problem of achieving reproducible builds and consistent development environments for Rust applications by leveraging Nix's dependency management and purity guarantees.
Rust developers and teams using or adopting the Nix package manager who need reproducible builds, granular caching for CI/CD, and declarative development environments for their projects.
Developers choose cargo2nix because it provides a seamless bridge between Cargo and Nix, offering the best of both worlds: Rust's rich crate ecosystem and Nix's reproducible, isolated builds without requiring a full rewrite of build logic.
Granular builds of Rust projects for Nix
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates Nix derivations for each crate, enabling fine-grained caching that skips redundant work in pipelines, as highlighted in the caching benefits.
Leverages Nix's purity to create identical builds across systems, eliminating 'works on my machine' issues through pure builds.
Automatically provides dev shells via workspaceShell with all dependencies and toolchains, allowing cargo build in isolated nix develop environments.
Supports packageOverrides to tweak crate builds, essential for fixing native library dependencies in sys crates, with examples in overrides.nix.
Requires writing and updating flake.nix and Cargo.nix files, with version mismatches that can break builds if inputs aren't carefully managed.
Git dependencies rely on builtins.fetchGit, which doesn't work with restrict-eval and requires manual updates for branches, as noted in common issues.
Building crates in isolation can lead to unnecessary builds of unneeded dependencies due to feature handling, impacting build times despite caching.