1{ stdenv, fetchFromGitHub, gnugrep
2, fixDarwinDylibNames
3, file
4, legacySupport ? false }:
5
6stdenv.mkDerivation rec {
7 name = "zstd-${version}";
8 version = "1.3.8";
9
10 src = fetchFromGitHub {
11 sha256 = "03jfbjzgqy5gvpym28r2phphdn536zvwfc6cw58ffk5ssm6blnqd";
12 rev = "v${version}";
13 repo = "zstd";
14 owner = "facebook";
15 };
16
17 buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
18
19 makeFlags = [
20 "ZSTD_LEGACY_SUPPORT=${if legacySupport then "1" else "0"}"
21 ];
22
23 checkInputs = [ file ];
24 doCheck = true;
25 preCheck = ''
26 substituteInPlace tests/playTests.sh \
27 --replace 'MD5SUM="md5 -r"' 'MD5SUM="md5sum"'
28 '';
29
30 installFlags = [
31 "PREFIX=$(out)"
32 ];
33
34 preInstall = ''
35 substituteInPlace programs/zstdgrep \
36 --replace "=grep" "=${gnugrep}/bin/grep" \
37 --replace "=zstdcat" "=$out/bin/zstdcat"
38
39 substituteInPlace programs/zstdless \
40 --replace "zstdcat" "$out/bin/zstdcat"
41 '';
42
43 meta = with stdenv.lib; {
44 description = "Zstandard real-time compression algorithm";
45 longDescription = ''
46 Zstd, short for Zstandard, is a fast lossless compression algorithm,
47 targeting real-time compression scenarios at zlib-level compression
48 ratio. Zstd can also offer stronger compression ratio at the cost of
49 compression speed. Speed/ratio trade-off is configurable by small
50 increment, to fit different situations. Note however that decompression
51 speed is preserved and remain roughly the same at all settings, a
52 property shared by most LZ compression algorithms, such as zlib.
53 '';
54 homepage = https://facebook.github.io/zstd/;
55 # The licence of the CLI programme is GPLv2+, that of the library BSD-2.
56 license = with licenses; [ gpl2Plus bsd2 ];
57
58 platforms = platforms.unix;
59 maintainers = with maintainers; [ orivej ];
60 };
61}