From c0e2f7bbbe8344ce6abb19b74f69336426c024e6 Mon Sep 17 00:00:00 2001 From: P-E-Meunier Date: Sun, 20 May 2018 11:28:19 +0100 Subject: [PATCH 1/2] buildRustCrate: add extraLinkFlags parameter This is useful when build scripts do not apply linking flags --- pkgs/build-support/rust/build-rust-crate.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/rust/build-rust-crate.nix b/pkgs/build-support/rust/build-rust-crate.nix index e0aec6e0e18b..5c738dd7f0b3 100644 --- a/pkgs/build-support/rust/build-rust-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate.nix @@ -47,7 +47,7 @@ let makeDeps = dependencies: ''; configureCrate = - { crateName, crateVersion, crateAuthors, build, libName, crateFeatures, colors, libPath, release, buildDependencies, completeDeps, completeBuildDeps, verbose, dependencies, workspace_member }: + { crateName, crateVersion, crateAuthors, build, libName, crateFeatures, colors, libPath, release, buildDependencies, completeDeps, completeBuildDeps, verbose, dependencies, workspace_member, extraLinkFlags }: let version_ = lib.splitString "-" crateVersion; versionPre = if lib.tail version_ == [] then "" else builtins.elemAt version_ 1; version = lib.splitString "." (lib.head version_); @@ -79,6 +79,8 @@ let makeDeps = dependencies: mkdir -p target/{deps,lib,build,buildDeps} chmod uga+w target -R + echo ${extraLinkFlags} > target/link + echo ${extraLinkFlags} > target/link.final for i in ${completeDepsDir}; do symlink_dependency $i target/deps done @@ -421,9 +423,11 @@ stdenv.mkDerivation (rec { if lib.attrByPath ["plugin"] false crate then "dylib" else (crate.type or "lib"); colors = lib.attrByPath [ "colors" ] "always" crate; + extraLinkFlags = builtins.concatStringsSep " " (crate.extraLinkFlags or []); configurePhase = configureCrate { inherit crateName dependencies buildDependencies completeDeps completeBuildDeps crateFeatures libName build workspace_member release libPath crateVersion + extraLinkFlags crateAuthors verbose colors; }; extraRustcOpts = if crate ? extraRustcOpts then crate.extraRustcOpts else []; From aa1d7961e74ee5b1743b1973c7e52128adf50fbe Mon Sep 17 00:00:00 2001 From: P-E-Meunier Date: Sun, 20 May 2018 11:28:35 +0100 Subject: [PATCH 2/2] curl-sys: fix linking against zlib --- pkgs/build-support/rust/default-crate-overrides.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/rust/default-crate-overrides.nix b/pkgs/build-support/rust/default-crate-overrides.nix index 971c4d0f5e22..d82a92042307 100644 --- a/pkgs/build-support/rust/default-crate-overrides.nix +++ b/pkgs/build-support/rust/default-crate-overrides.nix @@ -19,8 +19,9 @@ in crateBin = [ { name = "cargo-vendor"; path = "src/main.rs"; } ]; }; curl-sys = attrs: { - buildInputs = [ pkgconfig zlib ]; - propagatedBuiltInputs = [ curl ]; + buildInputs = [ pkgconfig zlib curl ]; + propagatedBuildInputs = [ curl zlib ]; + extraLinkFlags = ["-L${zlib.out}/lib"]; }; libgit2-sys = attrs: { LIBGIT2_SYS_USE_PKG_CONFIG = true;