6 , python3Support ? false
8 , log4cxxSupport ? false
10 , snappySupport ? false
17 , gtestSupport ? false
29 Check if null or false
31 let result = enableFeature null
33 let result = enableFeature false
35 let result = enableFeature «derivation»
38 enableCmakeFeature = p: if (p == null || p == false) then "OFF" else "ON";
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 boost179.override { inherit stdenv; enablePython = python3Support; python = python3; } else boost179;
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;
52 stdenv.mkDerivation rec {
57 hash = "sha256-IONnsSDbnX2qz+Xya0taHYSViTOiRI36AfcxmY3dNpo=";
58 url = "mirror://apache/pulsar/pulsar-${version}/apache-pulsar-${version}-src.tar.gz";
61 sourceRoot = "apache-pulsar-${version}-src/pulsar-client-cpp";
63 # clang-tools needed for clang-format
64 nativeBuildInputs = [ cmake pkg-config clangTools ]
66 ++ lib.optional gtestSupport gtest.dev;
68 buildInputs = [ jsoncpp openssl curl ]
71 # Needed for GCC on Linux
72 env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=return-type" ];
75 "-DBUILD_TESTS=${enableCmakeFeature gtestSupport}"
76 "-DBUILD_PYTHON_WRAPPER=${enableCmakeFeature python3Support}"
77 "-DUSE_LOG4CXX=${enableCmakeFeature log4cxxSupport}"
78 "-DClangTools_PATH=${clangTools}/bin"
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");
91 $CXX test.cc -L $out/lib -I $out/include -lpulsar -o test
95 homepage = "https://pulsar.apache.org/docs/en/client-libraries-cpp";
96 description = "Apache Pulsar C++ library";
98 platforms = platforms.all;
99 license = licenses.asl20;
100 maintainers = [ maintainers.corbanr ];