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