In the first case, it will build all the dependencies of foo separately of all the dependencies of bar if they do have different features flags. In the second case, it will take the union of feature flags of the packages. It will only build the common dependency crates once.
In case of crate2nix, we are forced to always use the first method. This becomes quite a bit of a problem if you have many workspaces in your project. If you have a crate called foo and then have 10 different crates bar1, bar2, …, bar10 that depend on it and set some various set of features, you are going to be compiling foo 10 times as far as I understand. This may be desirable and is what cargo does if we invoke -pbarN separately for each package.
It'd be quite nice if there was a way to just have a single foo and have all the packages use it however. I'm not sure if that's easy or not to do but it could save a lot of time.
Cargo has a questionable behaviour where
does not give the same result as
In the first case, it will build all the dependencies of
foo
separately of all the dependencies ofbar
if they do have different features flags. In the second case, it will take the union of feature flags of the packages. It will only build the common dependency crates once.In case of
crate2nix
, we are forced to always use the first method. This becomes quite a bit of a problem if you have many workspaces in your project. If you have a crate calledfoo
and then have 10 different cratesbar1
,bar2
, …,bar10
that depend on it and set some various set of features, you are going to be compilingfoo
10 times as far as I understand. This may be desirable and is what cargo does if we invoke-pbarN
separately for each package.It'd be quite nice if there was a way to just have a single
foo
and have all the packages use it however. I'm not sure if that's easy or not to do but it could save a lot of time.Relevant discussion on the Rust issue tracker https://github.com/rust-lang/cargo/issues/4463