Re:Rust 1.43
by steveklabnik on Friday April 24, 2020 @04:44PM
(#22972726)
> (unlike Rust where the entire dependency tree is vendored separately per package).
To be clear, Cargo downloads the source globally. The compiled output is per-project, however.
Nix uses `cargo vendor` to literally vendor the source of all dependencies as a separate derivation. Maybe cargo keeps a global cache of the source as well when doing `cargo vendor`, I don't know, but Nix does construct a derivation that contains just the vendored dependency sources and then provides that as input when building the full crate.
The end result is this bypasses npm's downloading and managing of node_modules, does it all in a fully declarative fashion, and then hands control over to npm to build the package. Also, each dependency's source is cached independently by Nix, so if multiple packages use the exact same dependency, it doesn't have to be redownloaded (unlike Rust where the entire dependency tree is vendored separately per package).