lol
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 boost,
7 zlib,
8 libevent,
9 openssl,
10 python3,
11 cmake,
12 pkg-config,
13 bison,
14 flex,
15 static ? stdenv.hostPlatform.isStatic,
16}:
17
18stdenv.mkDerivation rec {
19 pname = "thrift";
20 version = "0.18.1";
21
22 src = fetchurl {
23 url = "https://archive.apache.org/dist/thrift/${version}/${pname}-${version}.tar.gz";
24 hash = "sha256-BMbxDl14jKeOE+4u8NIVLHsHDAr1VIPWuULinP8pZyY=";
25 };
26
27 # Workaround to make the Python wrapper not drop this package:
28 # pythonFull.buildEnv.override { extraLibs = [ thrift ]; }
29 pythonPath = [ ];
30
31 nativeBuildInputs = [
32 bison
33 cmake
34 flex
35 pkg-config
36 (python3.withPackages (
37 ps:
38 with ps;
39 [
40 setuptools
41 six
42 ]
43 ++ lib.optionals (!static) [
44 twisted
45 ]
46 ))
47 ];
48
49 buildInputs = [
50 boost
51 ];
52
53 strictDeps = true;
54
55 propagatedBuildInputs = [
56 libevent
57 openssl
58 zlib
59 ];
60
61 postPatch = ''
62 # Python 3.10 related failures:
63 # SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
64 # AttributeError: module 'collections' has no attribute 'Hashable'
65 substituteInPlace test/py/RunClientServer.py \
66 --replace "'FastbinaryTest.py'," "" \
67 --replace "'TestEof.py'," "" \
68 --replace "'TestFrozen.py'," ""
69
70 # these functions are removed in Python3.12
71 substituteInPlace test/py/SerializationTest.py \
72 --replace-fail "assertEquals" "assertEqual" \
73 --replace-fail "assertNotEquals" "assertNotEqual"
74 '';
75
76 preConfigure = ''
77 export PY_PREFIX=$out
78 '';
79
80 patches = [
81 # ToStringTest.cpp is failing from some reason due to locale issue, this
82 # doesn't disable all UnitTests as in Darwin.
83 ./disable-failing-test.patch
84 (fetchpatch {
85 name = "setuptools-gte-62.1.0.patch"; # https://github.com/apache/thrift/pull/2635
86 url = "https://github.com/apache/thrift/commit/c41ad9d5119e9bdae1746167e77e224f390f2c42.diff";
87 hash = "sha256-FkErrg/6vXTomS4AsCsld7t+Iccc55ZiDaNjJ3W1km0=";
88 })
89 (fetchpatch {
90 name = "thrift-install-FindLibevent.patch"; # https://github.com/apache/thrift/pull/2726
91 url = "https://github.com/apache/thrift/commit/2ab850824f75d448f2ba14a468fb77d2594998df.diff";
92 hash = "sha256-ejMKFG/cJgoPlAFzVDPI4vIIL7URqaG06/IWdQ2NkhY=";
93 })
94 (fetchpatch {
95 name = "thrift-fix-tests-OpenSSL3.patch"; # https://github.com/apache/thrift/pull/2760
96 url = "https://github.com/apache/thrift/commit/eae3ac418f36c73833746bcd53e69ed8a12f0e1a.diff";
97 hash = "sha256-0jlN4fo94cfGFUKcLFQgVMI/x7uxn5OiLiFk6txVPzs=";
98 })
99 ];
100
101 cmakeFlags = [
102 "-DBUILD_JAVASCRIPT:BOOL=OFF"
103 "-DBUILD_NODEJS:BOOL=OFF"
104
105 # FIXME: Fails to link in static mode with undefined reference to
106 # `boost::unit_test::unit_test_main(bool (*)(), int, char**)'
107 "-DBUILD_TESTING:BOOL=${if static then "OFF" else "ON"}"
108 ]
109 ++ lib.optionals static [
110 "-DWITH_STATIC_LIB:BOOL=ON"
111 "-DOPENSSL_USE_STATIC_LIBS=ON"
112 ];
113
114 disabledTests = [
115 "PythonTestSSLSocket"
116 "PythonThriftTNonblockingServer"
117 ]
118 ++ lib.optionals stdenv.hostPlatform.isDarwin [
119 # Tests that hang up in the Darwin sandbox
120 "SecurityTest"
121 "SecurityFromBufferTest"
122 "python_test"
123
124 # fails on hydra, passes locally
125 "concurrency_test"
126
127 # Tests that fail in the Darwin sandbox when trying to use network
128 "UnitTests"
129 "TInterruptTest"
130 "TServerIntegrationTest"
131 "processor"
132 "TNonblockingServerTest"
133 "TNonblockingSSLServerTest"
134 "StressTest"
135 "StressTestConcurrent"
136 "StressTestNonBlocking"
137 ];
138
139 doCheck = !static;
140
141 checkPhase = ''
142 runHook preCheck
143
144 ${lib.optionalString stdenv.hostPlatform.isDarwin "DY"}LD_LIBRARY_PATH=$PWD/lib ctest -E "($(echo "$disabledTests" | tr " " "|"))"
145
146 runHook postCheck
147 '';
148
149 enableParallelChecking = false;
150
151 meta = with lib; {
152 description = "Library for scalable cross-language services";
153 mainProgram = "thrift";
154 homepage = "https://thrift.apache.org/";
155 license = licenses.asl20;
156 platforms = platforms.linux ++ platforms.darwin;
157 maintainers = with maintainers; [ bjornfor ];
158 };
159}