aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/tools/compression/zstd/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/compression/zstd/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/compression/zstd/default.nix28
1 files changed, 23 insertions, 5 deletions
diff --git a/nixpkgs/pkgs/tools/compression/zstd/default.nix b/nixpkgs/pkgs/tools/compression/zstd/default.nix
index 2f89331f92c..8ce434741a5 100644
--- a/nixpkgs/pkgs/tools/compression/zstd/default.nix
+++ b/nixpkgs/pkgs/tools/compression/zstd/default.nix
@@ -1,8 +1,9 @@
-{ stdenv, fetchFromGitHub, fetchpatch, cmake, gnugrep
+{ stdenv, fetchFromGitHub, fetchpatch, cmake, bash, gnugrep
, fixDarwinDylibNames
, file
, legacySupport ? false
-, enableShared ? true }:
+, static ? false
+}:
stdenv.mkDerivation rec {
pname = "zstd";
@@ -17,6 +18,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake ]
++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+ buildInputs = [ bash ];
patches = [
./playtests-darwin.patch
@@ -28,8 +30,20 @@ stdenv.mkDerivation rec {
# work fine, and I'm not sure how to write the condition.
++ stdenv.lib.optional stdenv.hostPlatform.isWindows ./mcfgthreads-no-pthread.patch;
+ postPatch = stdenv.lib.optionalString (!static) ''
+ substituteInPlace build/cmake/CMakeLists.txt \
+ --replace 'message(SEND_ERROR "You need to build static library to build tests")' ""
+ substituteInPlace build/cmake/tests/CMakeLists.txt \
+ --replace 'libzstd_static' 'libzstd_shared'
+ sed -i \
+ "1aexport ${stdenv.lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH=$PWD/build_/lib" \
+ tests/playTests.sh
+ '';
+
cmakeFlags = [
- "-DZSTD_BUILD_SHARED:BOOL=${if enableShared then "ON" else "OFF"}"
+ "-DZSTD_BUILD_SHARED:BOOL=${if (!static) then "ON" else "OFF"}"
+ "-DZSTD_BUILD_STATIC:BOOL=${if static then "ON" else "OFF"}"
+ "-DZSTD_PROGRAMS_LINK_SHARED:BOOL=${if (!static) then "ON" else "OFF"}"
"-DZSTD_LEGACY_SUPPORT:BOOL=${if legacySupport then "ON" else "OFF"}"
"-DZSTD_BUILD_TESTS:BOOL=ON"
];
@@ -43,6 +57,8 @@ stdenv.mkDerivation rec {
doCheck = true;
checkPhase = ''
runHook preCheck
+ # Patch shebangs for playTests
+ patchShebangs ../programs/zstdgrep
ctest -R playTests # The only relatively fast test.
runHook postCheck
'';
@@ -50,12 +66,14 @@ stdenv.mkDerivation rec {
preInstall = ''
substituteInPlace ../programs/zstdgrep \
--replace ":-grep" ":-${gnugrep}/bin/grep" \
- --replace ":-zstdcat" ":-$out/bin/zstdcat"
+ --replace ":-zstdcat" ":-$bin/bin/zstdcat"
substituteInPlace ../programs/zstdless \
- --replace "zstdcat" "$out/bin/zstdcat"
+ --replace "zstdcat" "$bin/bin/zstdcat"
'';
+ outputs = [ "bin" "dev" "man" "out" ];
+
meta = with stdenv.lib; {
description = "Zstandard real-time compression algorithm";
longDescription = ''