nix-community / crate2nix

rebuild only changed crates in CI with crate2nix and nix
https://nix-community.github.io/crate2nix/
Apache License 2.0
364 stars 86 forks source link

Git workspaces #298

Open tilpner opened 1 year ago

tilpner commented 1 year ago

This adds support for using workspaces in git dependencies with inherited fields, building upon #166 and #281. An example project which doesn't build on master, but works with this PR, can be found here.

166 takes care of exposing workspace members at the top level of a vendoring entry, so that cargo can find it, but it abducts the crate from its workspace without adjusting the manifest.

For example, the sqlx-postgres manifest inherits dependencies and metadata (edition, license) from the workspace manifest. These fields can't be filled in by cargo after copying the member crate out of the workspace, so this PR fills in that information before/while copying it out.

It does add a dependency on cargo's unstable API, which I found preferable to reimplementing the manifest inheritance on top of cargo_metadata, but I'd understand if it's an unacceptable choice for crate2nix. cargo (in the most recent version, which might not be required) also expects a very recent rustc.

The libgit2-sys dependencies are currently duplicated, due to lack of a central place to put them. If tools.nix could import default.nix, this wouldn't be a problem, but that seems to have been avoided so far, and would probably cause changes to the public interface.

If the commit message convention is out of place, or the drive-by "improvements" (don't shadow nix, use stable CLI) don't fit into this PR, we can change/drop them.

kolloch commented 11 months ago

Heyo @tilpner, I am not sure when I have time to think about this. But I already merged some of your commits on master, so thanks a lot!