@@ -1,4 +1,4 @@
1−{ stdenv, fetchFromGitHub, gnugrep
1+{ stdenv, fetchFromGitHub, fetchpatch, gnugrep
22, fixDarwinDylibNames
33, file
44, legacySupport ? false }:
@@ -14,11 +14,33 @@ stdenv.mkDerivation rec {
1414 owner = "facebook";
1515 };
1616
17− buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
17+ patches = [
18+ # All 3 from https://github.com/facebook/zstd/pull/1883
19+ (fetchpatch {
20+ url = "https://github.com/facebook/zstd/commit/106278e7e5fafaea3b7deb4147bdc8071562d2f0.diff";
21+ sha256 = "13z7id1qbc05cv1rmak7c8xrchp7jh1i623bq5pwcihg57wzcyr8";
22+ })
23+ (fetchpatch {
24+ url = "https://github.com/facebook/zstd/commit/0ede342acc2c26f87ae962fa88e158904d4198c4.diff";
25+ sha256 = "12l5xbvnzkvr76mvl1ls767paqfwbd9q1pzq44ckacfpz4f6iaap";
26+ excludes = [
27+ # I think line endings are causing problems, or something like that
28+ "programs/windres/generate_res.bat"
29+ ];
30+ })
31+ (fetchpatch {
32+ url = "https://github.com/facebook/zstd/commit/10552eaffef84c011f67af0e04f0780b50a5ab26.diff";
33+ sha256 = "1s27ravar3rn7q8abybp9733jhpsfcaci51k04da94ahahvxwiqw";
34+ })
35+ ] # This I didn't upstream because if you use posix threads with MinGW it will
36+ # work find, and I'm not sure how to write the condition.
37+ ++ stdenv.lib.optional stdenv.hostPlatform.isWindows ./mcfgthreads-no-pthread.patch;
38+
39+ nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
1840
1941 makeFlags = [
2042 "ZSTD_LEGACY_SUPPORT=${if legacySupport then "1" else "0"}"
21− ];
43+ ] ++ stdenv.lib.optional stdenv.hostPlatform.isWindows "OS=Windows";
2244
2345 checkInputs = [ file ];
2446 doCheck = true;
@@ -56,7 +78,7 @@ stdenv.mkDerivation rec {
5678 homepage = https://facebook.github.io/zstd/;
5779 license = with licenses; [ bsd3 ]; # Or, at your opinion, GPL-2.0-only.
5880
59− platforms = platforms.unix;
81+ platforms = platforms.all;
6082 maintainers = with maintainers; [ orivej ];
6183 };
6284}