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