Agreed. However, the main issue are vendoring changes. E.g. relatively recently there was a regression in cargo vendor
that changed permissions when unpacking sources. Many derivations that were updated during that window had wrong cargoSha256
s once the regression was fixed. I recently checked the cargoSha256
/cargoHash
of all buildRustPackage
derivations and more than 300 had incorrect hashes. We have had to fix cargoSha256
s several times over the last couple of years.
But nixpkgs is pretty much only packaging binary crates, which have dependencies locked through Cargo.lock
. So, for that use case Cargo and Nix both specify concrete dependencies.
To me, the primary issues are:
Cargo.toml
/Cargo.lock
do not provide enough metadata to make derivations for all dependencies at eval time (e.g. we do not know what dependencies are activated through features). We need to download and unpack all crates and read theirCargo.toml
s, e.g. throughcargo metadata
, to get the necessary metadata. This means that either the derivations should be generated through a separate step (e.g. runningcrate2nix
) or by using IFD.- Generating derivations for a substantial part of crates.io would probably add a lot of eval time to nixpkgs. This could have been acceptable with lazy eval, but as Rust trickles through the FLOSS ecosystem, it would add a lot of transitive dependencies (e.g. building GHC now depends on Rust/Cargo/various crates). Now such dependencies are cheap, because in the Rust build hooks we defer all dependency handling to Cargo. Though I guess flakes will make this more feasible, because evaluations can be cached.