-
Hullo! I've been learning to build Rust projects with crane, and I'm having a really excellent experience. And, there's a thing I really don't understand in the workspace quickstart flake. It demonstrates source loading with src = craneLib.cleanCargoSource ./.;
my-cli = craneLib.buildPackage (individualCrateArgs // {
pname = "my-cli";
cargoExtraArgs = "-p my-cli";
src = fileSetForCrate ./my-cli;
}); ...except now we're overriding I'm just trying to understand: why? Why not "just" use the Thanks so much for the help, and the excellent project! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @Gastove! It is totally fine to use the "entire", cleaned If you have a smaller project or don't care too much about the build invalidation, feel free to omit that extra code. Hope that explains things! |
Beta Was this translation helpful? Give feedback.
Hi @Gastove! It is totally fine to use the "entire", cleaned
src
for the workspace, but this has the effect that if you touch any file (kept by the filter) then all derivations which use that samesrc
will need to be rebuilt. Imagine you have a workspace of three crates:foo
,bar
, andcommon
, wherecommon
is a dependency of bothfoo
andbar
. Touching any of the source files forfoo
should not require rebuildingbar
, so if you have a slow build it may be more useful to apply thefileSetForCrate
technique to avoid accidental rebuilds (what this example illustrates is that only the top-level crate's source along with any common code is included for each leaf binary).If you have a smaller pr…