New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildRustPackage: support multiple cargo
invocations
#105825
buildRustPackage: support multiple cargo
invocations
#105825
Conversation
what is the use case ? |
I just pushed a new commit to demonstrate using different features for different crates within the same workspace. Does that help understanding the use-case? |
I see. Just so we can test, can you name a crate/project where this is needed? |
@symphorien of course. I'd like to integrate the changes made here with holochain/holochain#438. The binaries there share a large portion of common dependencies so it is rather inefficient to use separate packages. |
I hadn't seen that, thanks. I would prefer if the mechanism lived in nixpkgs itself, so I'm suggesting that we do merge this PR. I'll also take a look at crate2nix nonetheless. |
@lopsided98 @symphorien is there anything blocking this that I can help with? |
I must acknowledge that I don't really like this API. Possible suggestions:
{
preBuild = ''
runCargo --manifest-path foo bar
'';
}
What do you think? |
Well, I think we're unfortunately entering bike-shedding territory here. I prefer a Nix level solution or else I wouldn't have written it this way 😉 However, if you commit to approving the solution you outlined I'll implement it so we can get the functionality merged. |
Let's wait for another opinion then. |
I think this is quite nice and indeed a nice addition to the system. I think using the nix system seems more ergonomic and natural to me. I support the @steveej proposal. |
20188c6
to
2c42bfd
Compare
Thanks for the review @otavio. I rebased the PR and think we can merge this now. I haven't squashed the commits as I was previously told it makes reviewing harder. To the one who will merge this: please use the squash & merge button 🙂 |
Just squash them together as the chances that someone forgets it are pretty high. Also this needs to go through staging. |
This change allows calling `cargo build` multiple times with distinct flags. Please see the doc changes for more details.
f7f3875
to
8d87be1
Compare
Done 👍
You mean I should target the |
Yes, but that also requires quite some rewriting of this PR. |
@@ -35,6 +35,7 @@ | |||
, cargoUpdateHook ? "" | |||
, cargoDepsHook ? "" | |||
, cargoBuildFlags ? [] | |||
, cargoBuildFlagsMultiple ? [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @symphorien . And I don't think it is bikeshedding, API complexity and maintainability should be considered in changes. The buildRustPackage
API is already quite complex as it is. Unless this use-case becomes very frequent in nixpkgs, I think it is better that projects that need to do multiple builds with different feature flags use their own buildPhase
.
As @lopsided98 mentions, such cases are very well handled by buildRustCrate
plus crate2nix
, since it compiles every crate as a separate output path.
I hadn't seen that, thanks. I would prefer if the mechanism lived in nixpkgs itself, so I'm suggesting that we do merge this PR. I'll also take a look at crate2nix nonetheless.
crate2nix
is in nixpkgs and uses the buildRustCrate
functionality in nixpkgs. If you do not want to add a Cargo.nix
file in your repository and keep it up to date, crate2nix
also supports IFD to generate the Nix from Cargo.lock
.
I marked this as stale due to inactivity. → More info |
i haven't been using this myself so i won't pursue this PR any longer |
Motivation for this change
This change allows calling
cargo build
multiple times with distinctflags. Please see the doc changes for more details.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)