Skip to content
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

buildRustCrate: Allow version specific dependency renaming + parameter doc #84179

Merged
merged 2 commits into from
Apr 13, 2020

Conversation

kolloch
Copy link
Contributor

@kolloch kolloch commented Apr 3, 2020

This PR allows version specific crate renames:

pkgs.buildRustCrate {
  # ...
  crateRenames = {
     my_crate_name = [
         { version = "1.2.3"; rename = "my_alternative_name01" ; }
         { version = "3.2.3"; rename = "my_alternative_name03" ; }
     ];
     # ...
   };

I also documented all buildRustCrate parameters.

Motivation for this change

This roughly corresponds to the following snippet in Cargo.toml:

[dependencies]
my_alternative_name01 = { package = "my_crate_name", version = "0.1" }
my_alternative_name03 = { package = "my_crate_name", version = "0.3" }

Including multiple versions of a crate is very popular during ecosystem transitions, e.g. from futures 0.1 to futures 0.3.

Corresponding issue in crate2nix: nix-community/crate2nix#83

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s) nix build -f . buildRustCrateTests
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) (See above)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Copy link
Member

@andir andir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor remarks. Overall this looks good.

I also see the need for version specific overrides for things like (native)buildInputs.

Currently you have to "switch" on the version or name attribute in the overrides if you need different native inputs for the same crate name.

We should probably consider what larger refactoring we can do additionally to ease such pains.

I know, heretic, but...

I also know that this is not perfect but it is a good start, I think. It
would be nice if this were part of the automatic "nixdoc" function
reference. I'd like guidance if this should be part of the rust section
or something else.
@kolloch kolloch force-pushed the build-rust-crate-multi-version-rename branch from 4824a32 to bb660fe Compare April 9, 2020 22:56
@kolloch
Copy link
Contributor Author

kolloch commented Apr 9, 2020

Thank you for the review, @andir !

For buildInputs, the crateOverrides mechanism can be used. This PR is a bit special because it concerns the extern name with which a certain crate is used within a dependent crate. So maybe those separate concerns can be handled better but will still need to be handled differently.

@ofborg ofborg bot requested a review from andir April 9, 2020 23:02
@andir andir merged commit 310b5f6 into NixOS:master Apr 13, 2020
kolloch added a commit to nix-community/crate2nix that referenced this pull request May 29, 2020
arremoEngervetl added a commit to arremoEngervetl/crate2nix that referenced this pull request Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants