Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 103 lines 2.2 kB view raw
1{ 2 lib, 3 asioSupport ? true, 4 asio, 5 boost, 6 log4cxxSupport ? false, 7 log4cxx, 8 snappySupport ? false, 9 snappy, 10 zlibSupport ? true, 11 zlib, 12 zstdSupport ? true, 13 zstd, 14 gtest, 15 gtestSupport ? false, 16 cmake, 17 curl, 18 fetchFromGitHub, 19 protobuf, 20 jsoncpp, 21 openssl, 22 pkg-config, 23 stdenv, 24}: 25 26let 27 /* 28 Check if null or false 29 Example: 30 let result = enableFeature null 31 => "OFF" 32 let result = enableFeature false 33 => "OFF" 34 let result = enableFeature «derivation» 35 => "ON" 36 */ 37 enableCmakeFeature = p: if (p == null || p == false) then "OFF" else "ON"; 38 39 defaultOptionals = 40 [ protobuf ] 41 ++ lib.optional snappySupport snappy.dev 42 ++ lib.optional zlibSupport zlib 43 ++ lib.optional zstdSupport zstd 44 ++ lib.optional log4cxxSupport log4cxx 45 ++ lib.optional asioSupport asio 46 ++ lib.optional (!asioSupport) boost; 47 48in 49stdenv.mkDerivation (finalAttrs: rec { 50 pname = "libpulsar"; 51 version = "3.7.1"; 52 53 src = fetchFromGitHub { 54 owner = "apache"; 55 repo = "pulsar-client-cpp"; 56 rev = "v${version}"; 57 hash = "sha256-RHWi0KCq7U7Dr3Ic7kduc8P64VpAThTQ3lDxLLEqzIU="; 58 }; 59 60 nativeBuildInputs = 61 [ 62 cmake 63 pkg-config 64 ] 65 ++ defaultOptionals 66 ++ lib.optional gtestSupport gtest.dev; 67 68 buildInputs = [ 69 jsoncpp 70 openssl 71 curl 72 ] ++ defaultOptionals; 73 74 cmakeFlags = [ 75 "-DBUILD_TESTS=${enableCmakeFeature gtestSupport}" 76 "-DUSE_LOG4CXX=${enableCmakeFeature log4cxxSupport}" 77 "-DUSE_ASIO=${enableCmakeFeature asioSupport}" 78 ]; 79 80 doInstallCheck = true; 81 installCheckPhase = '' 82 echo ${lib.escapeShellArg '' 83 #include <pulsar/Client.h> 84 int main (int argc, char **argv) { 85 pulsar::Client client("pulsar://localhost:6650"); 86 return 0; 87 } 88 ''} > test.cc 89 $CXX test.cc -L $out/lib -I $out/include -lpulsar -o test 90 ''; 91 92 meta = with lib; { 93 homepage = "https://pulsar.apache.org/docs/next/client-libraries-cpp/"; 94 description = "Apache Pulsar C++ library"; 95 changelog = "https://github.com/apache/pulsar-client-cpp/releases/tag/v${version}"; 96 platforms = platforms.all; 97 license = licenses.asl20; 98 maintainers = with maintainers; [ 99 corbanr 100 gaelreyrol 101 ]; 102 }; 103})