1{ stdenv, lib, fetchurl, fetchFromGitHub, fixDarwinDylibNames, autoconf, boost
2, brotli, cmake, double-conversion, flatbuffers, gflags, glog, gtest, lz4, perl
3, python, rapidjson, snappy, thrift, uriparser, which, zlib, zstd
4, enableShared ? true }:
5
6let
7 parquet-testing = fetchFromGitHub {
8 owner = "apache";
9 repo = "parquet-testing";
10 rev = "a277dc4e55ded3e3ea27dab1e4faf98c112442df";
11 sha256 = "1yh5a8l4ship36hwmgmp2kl72s5ac9r8ly1qcs650xv2g9q7yhnq";
12 };
13
14in stdenv.mkDerivation rec {
15 pname = "arrow-cpp";
16 version = "0.15.1";
17
18 src = fetchurl {
19 url =
20 "mirror://apache/arrow/arrow-${version}/apache-arrow-${version}.tar.gz";
21 sha256 = "1jbghpppabsix2rkxbnh41inj9lcxfz4q94p96xzxshh4g3mhb4s";
22 };
23
24 sourceRoot = "apache-arrow-${version}/cpp";
25
26 ARROW_JEMALLOC_URL = fetchurl {
27 # From
28 # ./cpp/cmake_modules/ThirdpartyToolchain.cmake
29 # ./cpp/thirdparty/versions.txt
30 url =
31 "https://github.com/jemalloc/jemalloc/releases/download/5.2.0/jemalloc-5.2.0.tar.bz2";
32 sha256 = "1d73a5c5qdrwck0fa5pxz0myizaf3s9alsvhiqwrjahdlr29zgkl";
33 };
34
35 patches = [
36 # patch to fix python-test
37 ./darwin.patch
38 ] ++ lib.optionals (!enableShared) [
39 # The shared jemalloc lib is unused and breaks in static mode due to missing -fpic.
40 ./jemalloc-disable-shared.patch
41 ];
42
43 nativeBuildInputs = [
44 cmake
45 autoconf # for vendored jemalloc
46 flatbuffers
47 ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
48 buildInputs = [
49 boost
50 brotli
51 double-conversion
52 flatbuffers
53 gflags
54 glog
55 gtest
56 lz4
57 rapidjson
58 snappy
59 thrift
60 uriparser
61 zlib
62 zstd
63 python.pkgs.python
64 python.pkgs.numpy
65 ];
66
67 preConfigure = ''
68 substituteInPlace cmake_modules/FindLz4.cmake --replace CMAKE_STATIC_LIBRARY CMAKE_SHARED_LIBRARY
69
70 patchShebangs build-support/
71 '';
72
73 cmakeFlags = [
74 "-DARROW_BUILD_TESTS=ON"
75 "-DARROW_DEPENDENCY_SOURCE=SYSTEM"
76 "-DARROW_PARQUET=ON"
77 "-DARROW_PLASMA=ON"
78 # Disable Python for static mode because openblas is currently broken there.
79 "-DARROW_PYTHON=${if enableShared then "ON" else "OFF"}"
80 "-Duriparser_SOURCE=SYSTEM"
81 ] ++ lib.optionals (!enableShared) [
82 "-DARROW_BUILD_SHARED=OFF"
83 "-DARROW_TEST_LINKAGE=static"
84 "-DOPENSSL_USE_STATIC_LIBS=ON"
85 ] ++ lib.optional (!stdenv.isx86_64) "-DARROW_USE_SIMD=OFF";
86
87 doInstallCheck = true;
88 PARQUET_TEST_DATA =
89 if doInstallCheck then "${parquet-testing}/data" else null;
90 installCheckInputs = [ perl which ];
91 installCheckPhase = (lib.optionalString stdenv.isDarwin ''
92 for f in release/*test{,s}; do
93 install_name_tool -add_rpath "$out"/lib "$f"
94 done
95 '')
96 + (let
97 excludedTests = lib.optionals stdenv.isDarwin [
98 # Some plasma tests need to be patched to use a shorter AF_UNIX socket
99 # path on Darwin. See https://github.com/NixOS/nix/pull/1085
100 "plasma-external-store-tests"
101 "plasma-client-tests"
102 ];
103 in ''
104 ctest -L unittest -V \
105 --exclude-regex '^(${builtins.concatStringsSep "|" excludedTests})$'
106 '');
107
108 meta = {
109 description = "A cross-language development platform for in-memory data";
110 homepage = "https://arrow.apache.org/";
111 license = lib.licenses.asl20;
112 platforms = lib.platforms.unix;
113 maintainers = with lib.maintainers; [ tobim veprbl ];
114 };
115}