From 85c6d720117f8207ba561804980b2452755170b8 Mon Sep 17 00:00:00 2001 From: Daniƫl de Kok Date: Sun, 8 Sep 2019 08:18:09 +0200 Subject: buildRustCrate: add support for renaming crates Before this change, buildRustCrate always called rustc with --extern libName=[...]libName[...] However, Cargo permits using a different name under which a dependency is known to a crate. For example, rand 0.7.0 uses: [dependencies] getrandom_package = { version = "0.1.1", package = "getrandom", optional = true } Which introduces the getrandom dependency such that it is known as getrandom_package to the rand crate. In this case, the correct extern flag is of the form --extern getrandom_package=[...]getrandom[...] which is currently not supported. In order to support such cases, this change introduces a crateRenames argument to buildRustCrate. This argument is an attribute set of dependencies that should be renamed. In this case, crateRenames would be: { "getrandom" = "getrandom_package"; } The extern options are then built such that if the libName occurs as an attribute in this set, it value will be used as the local name. Otherwise libName will be used as before. --- pkgs/build-support/rust/build-rust-crate/build-crate.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkgs/build-support/rust/build-rust-crate/build-crate.nix') diff --git a/pkgs/build-support/rust/build-rust-crate/build-crate.nix b/pkgs/build-support/rust/build-rust-crate/build-crate.nix index 2999c3d4c1d..e0a52e62561 100644 --- a/pkgs/build-support/rust/build-rust-crate/build-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/build-crate.nix @@ -1,13 +1,13 @@ { lib, stdenv, echo_build_heading, noisily, makeDeps }: { crateName, dependencies, - crateFeatures, libName, release, libPath, + crateFeatures, crateRenames, libName, release, libPath, crateType, metadata, crateBin, hasCrateBin, extraRustcOpts, verbose, colors }: let - deps = makeDeps dependencies; + deps = makeDeps dependencies crateRenames; rustcOpts = lib.lists.foldl' (opts: opt: opts + " " + opt) (if release then "-C opt-level=3" else "-C debuginfo=2") -- cgit 1.4.1