NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.86k stars 13.93k forks source link

buildRustCrate does not handle renames #68249

Closed danieldk closed 5 years ago

danieldk commented 5 years ago

Describe the bug

buildRustCrate and accompanying tools such as Carnix, does not handle renames in Cargo.toml. This is likely to become a more serious issue for users of buildRustCrate soon, since rand 0.7.0 uses a rename:

getrandom_package = { version = "0.1.1", package = "getrandom", optional = true }

In such cases, the right invocation of rustc adds an extern option like the following:

--extern getrandom_package=[...]/libgetrandom-[...].rlib

However, buildRustCrate with Carnix-generated files currently adds

--extern getrandom=[...]/libgetrandom-[...].rlib

This issue has been reported in the bug trackers of Carnix and crate2nix, but I thought it would be good to have an issue in the nixpkgs issue tracker in case people run into this issue.

https://nest.pijul.com/pmeunier/carnix/discussions/35 https://github.com/kolloch/crate2nix/issues/22

To Reproduce

  1. Use carnix to generate nix files from a Cargo.toml that has rand == 0.7 as a transitive dependency.
  2. Build using nix-build

Expected behavior

The build succeeds, because it adds the correct --extern argument.

gilligan commented 5 years ago

i created the issues with carnix and crate2nix and have since also created a little test project: https://github.com/gilligan/rs-nix-test

I guess i might be able to fix/add support for this in crate2nix but I prefer to not touch the carnix code base and haven't received any feedback from the author despite multiple attempts on different channels.

danieldk commented 5 years ago

Fixed in #68296