nushell: use cargo-edit instead of a patch to add pkg-config feature

to zstd-sys

cargo add has been merged in to cargo so the extra package won't be
needed once 1.62.0 is available in nixpkgs
This commit is contained in:
Artturin 2022-05-28 22:10:16 +03:00
parent 9ca1379bdf
commit 7d735f01a4
2 changed files with 18 additions and 46 deletions

View File

@ -13,6 +13,7 @@
, Security
, nghttp2
, libgit2
, cargo-edit
, withExtraFeatures ? true
, testers
, nushell
@ -29,7 +30,23 @@ rustPlatform.buildRustPackage rec {
sha256 = "sha256-4thvUSOSvH/bv0aW7hGGQMvtXdS+yDfZzPRLZmPZQMQ=";
};
cargoSha256 = "sha256-ALUp6sPcmnJy/A078umyKg8KBv23P0vv8mwoO9OU+DQ=";
cargoSha256 = "sha256-Vd8R9EsO52q840HqRzc37PirZZyTZr+Bnow5qHEacJ0=";
# Since 0.34, nu has an indirect dependency on `zstd-sys` (via `polars` and
# `parquet`, for dataframe support), which by default has an impure build
# (git submodule for the `zstd` C library). The `pkg-config` feature flag
# fixes this, but it's hard to invoke this in the right place, because of
# the indirect dependencies. So add a direct dependency on `zstd-sys` here
# at the top level, along with this feature flag, to ensure that when
# `zstd-sys` is transitively invoked, it triggers a pure build using the
# system `zstd` library provided above.
depsExtraArgs = { nativeBuildInputs = [ cargo-edit ]; };
# cargo add has been merged in to cargo so the above can be removed once 1.62.0 is available in nixpkgs
# https://github.com/rust-lang/cargo/pull/10472
cargoUpdateHook = ''
cargo add zstd-sys --features pkg-config --offline
# write the change to the lockfile
cargo update --package zstd-sys --offline
'';
nativeBuildInputs = [ pkg-config ]
++ lib.optionals (withExtraFeatures && stdenv.isLinux) [ python3 ];
@ -41,19 +58,6 @@ rustPlatform.buildRustPackage rec {
buildFeatures = lib.optional withExtraFeatures "extra";
# Since 0.34, nu has an indirect dependency on `zstd-sys` (via `polars` and
# `parquet`, for dataframe support), which by default has an impure build
# (git submodule for the `zstd` C library). The `pkg-config` feature flag
# fixes this, but it's hard to invoke this in the right place, because of
# the indirect dependencies. So add a direct dependency on `zstd-sys` here
# at the top level, along with this feature flag, to ensure that when
# `zstd-sys` is transitively invoked, it triggers a pure build using the
# system `zstd` library provided above.
#
# (If this patch needs updating, in a nushell repo add the zstd-sys line to
# Cargo.toml, then `cargo update --package zstd-sys` to update Cargo.lock.)
cargoPatches = [ ./use-system-zstd-lib.diff ];
# TODO investigate why tests are broken on darwin
# failures show that tests try to write to paths
# outside of TMPDIR

View File

@ -1,32 +0,0 @@
diff --git a/Cargo.lock b/Cargo.lock
index 6cebf66d..b6e40cd9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2443,6 +2443,7 @@ dependencies = [
"rstest",
"serial_test",
"tempfile",
+ "zstd-sys",
]
[[package]]
@@ -5365,4 +5366,5 @@ checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b"
dependencies = [
"cc",
"libc",
+ "pkg-config",
]
diff --git a/Cargo.toml b/Cargo.toml
index 0791d462..d520d9ae 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -58,6 +58,9 @@ rayon = "1.5.1"
reedline = { version = "0.6.0", features = ["bashisms"]}
is_executable = "1.0.1"
+# Specify that the indirect dependency ztsd-sys should pick up the system zstd C library
+zstd-sys = { version = "2", features = [ "pkg-config" ] }
+
[dev-dependencies]
nu-test-support = { path="./crates/nu-test-support", version = "0.63.0" }
tempfile = "3.2.0"