at 23.05-pre 102 lines 2.8 kB view raw
1{ lib 2, clang-tools 3, llvmPackages 4, boost17x 5, protobuf 6, python3Support ? false 7, python3 8, log4cxxSupport ? false 9, log4cxx 10, snappySupport ? false 11, snappy 12, zlibSupport ? true 13, zlib 14, zstdSupport ? true 15, zstd 16, gtest 17, gtestSupport ? false 18, cmake 19, curl 20, fetchurl 21, jsoncpp 22, openssl 23, pkg-config 24, stdenv 25}: 26 27let 28 /* 29 Check if null or false 30 Example: 31 let result = enableFeature null 32 => "OFF" 33 let result = enableFeature false 34 => "OFF" 35 let result = enableFeature «derivation» 36 => "ON" 37 */ 38 enableCmakeFeature = p: if (p == null || p == false) then "OFF" else "ON"; 39 40 # Not really sure why I need to do this.. If I call clang-tools without the override it defaults to a different version and fails 41 clangTools = clang-tools.override { inherit stdenv llvmPackages; }; 42 # If boost has python enabled, then boost-python package will be installed which is used by libpulsars python wrapper 43 boost = if python3Support then boost17x.override { inherit stdenv; enablePython = python3Support; python = python3; } else boost17x; 44 defaultOptionals = [ boost protobuf ] 45 ++ lib.optional python3Support python3 46 ++ lib.optional snappySupport snappy.dev 47 ++ lib.optional zlibSupport zlib 48 ++ lib.optional zstdSupport zstd 49 ++ lib.optional log4cxxSupport log4cxx; 50 51in 52stdenv.mkDerivation rec { 53 pname = "libpulsar"; 54 version = "2.10.2"; 55 56 src = fetchurl { 57 hash = "sha256-IONnsSDbnX2qz+Xya0taHYSViTOiRI36AfcxmY3dNpo="; 58 url = "mirror://apache/pulsar/pulsar-${version}/apache-pulsar-${version}-src.tar.gz"; 59 }; 60 61 sourceRoot = "apache-pulsar-${version}-src/pulsar-client-cpp"; 62 63 # clang-tools needed for clang-format 64 nativeBuildInputs = [ cmake pkg-config clangTools ] 65 ++ defaultOptionals 66 ++ lib.optional gtestSupport gtest.dev; 67 68 buildInputs = [ jsoncpp openssl curl ] 69 ++ defaultOptionals; 70 71 # Needed for GCC on Linux 72 NIX_CFLAGS_COMPILE = [ "-Wno-error=return-type" ]; 73 74 cmakeFlags = [ 75 "-DBUILD_TESTS=${enableCmakeFeature gtestSupport}" 76 "-DBUILD_PYTHON_WRAPPER=${enableCmakeFeature python3Support}" 77 "-DUSE_LOG4CXX=${enableCmakeFeature log4cxxSupport}" 78 "-DClangTools_PATH=${clangTools}/bin" 79 ]; 80 81 enableParallelBuilding = true; 82 doInstallCheck = true; 83 installCheckPhase = '' 84 echo ${lib.escapeShellArg '' 85 #include <pulsar/Client.h> 86 int main (int argc, char **argv) { 87 pulsar::Client client("pulsar://localhost:6650"); 88 return 0; 89 } 90 ''} > test.cc 91 $CXX test.cc -L $out/lib -I $out/include -lpulsar -o test 92 ''; 93 94 meta = with lib; { 95 homepage = "https://pulsar.apache.org/docs/en/client-libraries-cpp"; 96 description = "Apache Pulsar C++ library"; 97 98 platforms = platforms.all; 99 license = licenses.asl20; 100 maintainers = [ maintainers.corbanr ]; 101 }; 102}