1 { lib, stdenv, fetchFromGitHub, fetchpatch, valgrind
2 , enableStatic ? stdenv.hostPlatform.isStatic
3 , enableShared ? !stdenv.hostPlatform.isStatic
6 stdenv.mkDerivation rec {
10 src = fetchFromGitHub {
11 sha256 = "sha256-YiMCD3vvrG+oxBUghSrCmP2LAfAGZrEaKz0YoaQJhpI=";
18 (fetchpatch { # https://github.com/lz4/lz4/pull/1162
19 name = "build-shared-no.patch";
20 url = "https://github.com/lz4/lz4/commit/851ef4b23c7cbf4ceb2ba1099666a8b5ec4fa195.patch";
21 sha256 = "sha256-P+/uz3m7EAmHgXF/1Vncc0uKKxNVq6HNIsElx0rGxpw=";
25 # TODO(@Ericson2314): Separate binaries and libraries
26 outputs = [ "bin" "out" "dev" ];
28 buildInputs = lib.optional doCheck valgrind;
30 enableParallelBuilding = true;
34 "INCLUDEDIR=$(dev)/include"
35 "BUILD_STATIC=${if enableStatic then "yes" else "no"}"
36 "BUILD_SHARED=${if enableShared then "yes" else "no"}"
37 "WINDRES:=${stdenv.cc.bintools.targetPrefix}windres"
39 # TODO make full dictionary
40 ++ lib.optional stdenv.hostPlatform.isMinGW "TARGET_OS=MINGW"
43 doCheck = false; # tests take a very long time
46 # TODO(@Ericson2314): Make resusable setup hook for this issue on Windows.
48 lib.optionalString stdenv.hostPlatform.isWindows ''
49 mv $out/bin/*.dll $out/lib
53 moveToOutput bin "$bin"
57 description = "Extremely fast compression algorithm";
59 Very fast lossless compression algorithm, providing compression speed
60 at 400 MB/s per core, with near-linear scalability for multi-threaded
61 applications. It also features an extremely fast decoder, with speed in
62 multiple GB/s per core, typically reaching RAM speed limits on
65 homepage = "https://lz4.github.io/lz4/";
66 license = with licenses; [ bsd2 gpl2Plus ];
67 platforms = platforms.all;