From 03e499425d2f3968eeb9b568d0350b6cf3da6b64 Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Sat, 10 Jul 2021 12:08:31 -0700 Subject: [PATCH] zstd: don't build contrib when cross-compiling Tests and `./gen_html` from contrib need to run on host architecture. Disable them when doing cross-compiliation. --- pkgs/tools/compression/zstd/default.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/compression/zstd/default.nix b/pkgs/tools/compression/zstd/default.nix index 5253d7faa401..16504d50dbf4 100644 --- a/pkgs/tools/compression/zstd/default.nix +++ b/pkgs/tools/compression/zstd/default.nix @@ -3,6 +3,9 @@ , file , legacySupport ? false , static ? stdenv.hostPlatform.isStatic +# these need to be ran on the host, thus disable when cross-compiling +, buildContrib ? stdenv.hostPlatform == stdenv.buildPlatform +, doCheck ? stdenv.hostPlatform == stdenv.buildPlatform }: stdenv.mkDerivation rec { @@ -40,7 +43,7 @@ stdenv.mkDerivation rec { (name: value: "-DZSTD_${name}:BOOL=${if value then "ON" else "OFF"}") { BUILD_SHARED = !static; BUILD_STATIC = static; - BUILD_CONTRIB = true; + BUILD_CONTRIB = buildContrib; PROGRAMS_LINK_SHARED = !static; LEGACY_SUPPORT = legacySupport; BUILD_TESTS = doCheck; @@ -53,7 +56,7 @@ stdenv.mkDerivation rec { ''; checkInputs = [ file ]; - doCheck = stdenv.hostPlatform == stdenv.buildPlatform; + inherit doCheck; checkPhase = '' runHook preCheck # Patch shebangs for playTests @@ -64,7 +67,6 @@ stdenv.mkDerivation rec { preInstall = '' mkdir -p $bin/bin - cp contrib/pzstd/pzstd $bin/bin/pzstd substituteInPlace ../programs/zstdgrep \ --replace ":-grep" ":-${gnugrep}/bin/grep" \ --replace ":-zstdcat" ":-$bin/bin/zstdcat" @@ -73,6 +75,8 @@ stdenv.mkDerivation rec { --replace "zstdcat" "$bin/bin/zstdcat" '' + lib.optionalString stdenv.isDarwin '' install_name_tool -change @rpath/libzstd.1.dylib $out/lib/libzstd.1.dylib $bin/bin/pzstd + '' + lib.optionalString buildContrib '' + cp contrib/pzstd/pzstd $bin/bin/pzstd ''; outputs = [ "bin" "dev" ]