1{ stdenv, lib, fetchurl, fetchFromGitHub, fixDarwinDylibNames
2, autoconf, boost, brotli, cmake, flatbuffers, gflags, glog, gtest, lz4
3, perl, python3, rapidjson, re2, snappy, thrift, utf8proc, which, xsimd
4, zlib, zstd
5, enableShared ? !stdenv.hostPlatform.isStatic
6}:
7
8let
9 arrow-testing = fetchFromGitHub {
10 owner = "apache";
11 repo = "arrow-testing";
12 rev = "d6c4deb22c4b4e9e3247a2f291046e3c671ad235";
13 sha256 = "0cwhnqijam632zp07j98i8ym967wz6kd35fim1msv88x2rhqky1i";
14 };
15
16 parquet-testing = fetchFromGitHub {
17 owner = "apache";
18 repo = "parquet-testing";
19 rev = "ddd898958803cb89b7156c6350584d1cda0fe8de";
20 sha256 = "0n16xqlpxn2ryp43w8pppxrbwmllx6sk4hv3ycgikfj57nd3ibc0";
21 };
22
23in stdenv.mkDerivation rec {
24 pname = "arrow-cpp";
25 version = "4.0.1";
26
27 src = fetchurl {
28 url =
29 "mirror://apache/arrow/arrow-${version}/apache-arrow-${version}.tar.gz";
30 sha256 = "0vl926i6jvsvj5vigdgqzp9v1i1h5zzj1abqr6qwc9drfsibzk3m";
31 };
32 sourceRoot = "apache-arrow-${version}/cpp";
33
34 ARROW_JEMALLOC_URL = fetchurl {
35 # From
36 # ./cpp/cmake_modules/ThirdpartyToolchain.cmake
37 # ./cpp/thirdparty/versions.txt
38 url =
39 "https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2";
40 sha256 = "1xl7z0vwbn5iycg7amka9jd6hxd8nmfk7nahi4p9w2bnw9f0wcrl";
41 };
42
43 ARROW_MIMALLOC_URL = fetchurl {
44 # From
45 # ./cpp/cmake_modules/ThirdpartyToolchain.cmake
46 # ./cpp/thirdparty/versions.txt
47 url =
48 "https://github.com/microsoft/mimalloc/archive/v1.6.4.tar.gz";
49 sha256 = "1b8av0974q70alcmaw5cwzbn6n9blnpmj721ik1qwmbbwwd6nqgs";
50 };
51
52 patches = [
53 # patch to fix python-test
54 ./darwin.patch
55 ];
56
57 nativeBuildInputs = [
58 cmake
59 autoconf # for vendored jemalloc
60 flatbuffers
61 ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
62 buildInputs = [
63 boost
64 brotli
65 flatbuffers
66 gflags
67 glog
68 gtest
69 lz4
70 rapidjson
71 re2
72 snappy
73 thrift
74 utf8proc
75 zlib
76 zstd
77 ] ++ lib.optionals enableShared [
78 python3.pkgs.python
79 python3.pkgs.numpy
80 ];
81
82 preConfigure = ''
83 patchShebangs build-support/
84 '';
85
86 cmakeFlags = [
87 "-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON"
88 "-DARROW_BUILD_SHARED=${if enableShared then "ON" else "OFF"}"
89 "-DARROW_BUILD_STATIC=${if enableShared then "OFF" else "ON"}"
90 "-DARROW_BUILD_TESTS=ON"
91 "-DARROW_VERBOSE_THIRDPARTY_BUILD=ON"
92 "-DARROW_DEPENDENCY_SOURCE=SYSTEM"
93 "-DARROW_DEPENDENCY_USE_SHARED=${if enableShared then "ON" else "OFF"}"
94 "-DARROW_COMPUTE=ON"
95 "-DARROW_CSV=ON"
96 "-DARROW_DATASET=ON"
97 "-DARROW_JSON=ON"
98 "-DARROW_PLASMA=ON"
99 # Disable Python for static mode because openblas is currently broken there.
100 "-DARROW_PYTHON=${if enableShared then "ON" else "OFF"}"
101 "-DARROW_USE_GLOG=ON"
102 "-DARROW_WITH_BROTLI=ON"
103 "-DARROW_WITH_LZ4=ON"
104 "-DARROW_WITH_SNAPPY=ON"
105 "-DARROW_WITH_UTF8PROC=ON"
106 "-DARROW_WITH_ZLIB=ON"
107 "-DARROW_WITH_ZSTD=ON"
108 "-DARROW_MIMALLOC=ON"
109 # Parquet options:
110 "-DARROW_PARQUET=ON"
111 "-DPARQUET_BUILD_EXECUTABLES=ON"
112 ] ++ lib.optionals (!enableShared) [
113 "-DARROW_TEST_LINKAGE=static"
114 ] ++ lib.optionals stdenv.isDarwin [
115 "-DCMAKE_SKIP_BUILD_RPATH=OFF" # needed for tests
116 "-DCMAKE_INSTALL_RPATH=@loader_path/../lib" # needed for tools executables
117 ] ++ lib.optional (!stdenv.isx86_64) "-DARROW_USE_SIMD=OFF";
118
119 ARROW_XSIMD_URL = xsimd.src;
120
121 doInstallCheck = true;
122 ARROW_TEST_DATA =
123 if doInstallCheck then "${arrow-testing}/data" else null;
124 PARQUET_TEST_DATA =
125 if doInstallCheck then "${parquet-testing}/data" else null;
126 GTEST_FILTER =
127 if doInstallCheck then let
128 # Upstream Issue: https://issues.apache.org/jira/browse/ARROW-11398
129 filteredTests = lib.optionals stdenv.hostPlatform.isAarch64 [
130 "TestFilterKernelWithNumeric/3.CompareArrayAndFilterRandomNumeric"
131 "TestFilterKernelWithNumeric/7.CompareArrayAndFilterRandomNumeric"
132 "TestCompareKernel.PrimitiveRandomTests"
133 ];
134 in "-${builtins.concatStringsSep ":" filteredTests}" else null;
135 installCheckInputs = [ perl which ];
136 installCheckPhase =
137 let
138 excludedTests = lib.optionals stdenv.isDarwin [
139 # Some plasma tests need to be patched to use a shorter AF_UNIX socket
140 # path on Darwin. See https://github.com/NixOS/nix/pull/1085
141 "plasma-external-store-tests"
142 "plasma-client-tests"
143 ];
144 in ''
145 ctest -L unittest -V \
146 --exclude-regex '^(${builtins.concatStringsSep "|" excludedTests})$'
147 '';
148
149 meta = with lib; {
150 description = "A cross-language development platform for in-memory data";
151 homepage = "https://arrow.apache.org/";
152 license = licenses.asl20;
153 platforms = platforms.unix;
154 maintainers = with maintainers; [ tobim veprbl ];
155 };
156}