Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions pkgs/tools/compression/zstd/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ stdenv, fetchFromGitHub, gnugrep
{ stdenv, fetchFromGitHub, fetchpatch, cmake, gnugrep
, fixDarwinDylibNames
, file
, legacySupport ? false }:
, legacySupport ? false
, static ? false }:

stdenv.mkDerivation rec {
pname = "zstd";
Expand All @@ -14,34 +15,42 @@ stdenv.mkDerivation rec {
owner = "facebook";
};

outputs = [ "out" "lib" "dev" ];

buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;

makeFlags = [
"ZSTD_LEGACY_SUPPORT=${if legacySupport then "1" else "0"}"
nativeBuildInputs = [ cmake ];
patches = [(fetchpatch {
url = "https://github.com/facebook/zstd/commit/bda4669edc38c61e033bcf3905932e6d79c9d64a.diff";
sha256 = "0asnslwb5k6g8yfr263fddarfmawsmvpdvbfyww773na2mmvhk66";
})];
cmakeFlags = [
"-DZSTD_BUILD_SHARED:BOOL=${if static then "OFF" else "ON"}"
"-DZSTD_LEGACY_SUPPORT:BOOl=${if legacySupport then "ON" else "OFF"}"
"-DZSTD_BUILD_TESTS:BOOL=ON"
];
cmakeDir = "../build/cmake";
dontUseCmakeBuildDir = true;
preConfigure = ''
mkdir -p build_ && cd $_
'';

checkInputs = [ file ];
doCheck = true;
preCheck = ''
substituteInPlace tests/playTests.sh \
substituteInPlace ../tests/playTests.sh \
--replace 'MD5SUM="md5 -r"' 'MD5SUM="md5sum"'
'';

installFlags = [
"PREFIX=$(out)"
];

preInstall = ''
substituteInPlace programs/zstdgrep \
preInstall = stdenv.lib.optionalString (!static) ''
substituteInPlace ../programs/zstdgrep \
--replace ":-grep" ":-${gnugrep}/bin/grep" \
--replace ":-zstdcat" ":-$out/bin/zstdcat"

substituteInPlace programs/zstdless \
substituteInPlace ../programs/zstdless \
--replace "zstdcat" "$out/bin/zstdcat"
'';

enableParallelBuilding = true;

meta = with stdenv.lib; {
description = "Zstandard real-time compression algorithm";
longDescription = ''
Expand Down
4 changes: 4 additions & 0 deletions pkgs/top-level/static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ in {
staticOnly = true;
};

zstd = super.zstd.override {
static = true;
};

llvmPackages_8 = super.llvmPackages_8 // {
libraries = super.llvmPackages_8.libraries // rec {
libcxxabi = super.llvmPackages_8.libraries.libcxxabi.override {
Expand Down