at master 104 lines 2.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 cmake, 6 gtest, 7 protobuf, 8 curl, 9 grpc, 10 prometheus-cpp, 11 nlohmann_json, 12 nix-update-script, 13 cxxStandard ? null, 14 enableHttp ? false, 15 enableGrpc ? false, 16 enablePrometheus ? false, 17 enableElasticSearch ? false, 18 enableZipkin ? false, 19}: 20let 21 opentelemetry-proto = fetchFromGitHub { 22 owner = "open-telemetry"; 23 repo = "opentelemetry-proto"; 24 rev = "v1.7.0"; 25 hash = "sha256-3SFf/7fStrglxcpwEya7hDp8Sr3wBG9OYyBoR78IUgs="; 26 }; 27in 28stdenv.mkDerivation (finalAttrs: { 29 pname = "opentelemetry-cpp"; 30 version = "1.23.0"; 31 32 src = fetchFromGitHub { 33 owner = "open-telemetry"; 34 repo = "opentelemetry-cpp"; 35 rev = "v${finalAttrs.version}"; 36 hash = "sha256-4SmKB2368I/2WTKYCqsZAAdkJygA15zCT+I7/RF8Knk="; 37 }; 38 39 patches = [ 40 ./0001-Disable-tests-requiring-network-access.patch 41 ] 42 ++ lib.optional stdenv.hostPlatform.isDarwin ./0002-Disable-segfaulting-test-on-Darwin.patch; 43 44 nativeBuildInputs = [ cmake ]; 45 46 buildInputs = [ 47 curl 48 nlohmann_json 49 ]; 50 51 propagatedBuildInputs = 52 lib.optionals (enableGrpc || enableHttp) [ protobuf ] 53 ++ lib.optionals enableGrpc [ 54 grpc 55 ] 56 ++ lib.optionals enablePrometheus [ 57 prometheus-cpp 58 ]; 59 60 doCheck = true; 61 62 checkInputs = [ 63 gtest 64 ]; 65 66 strictDeps = true; 67 68 cmakeFlags = [ 69 (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) 70 (lib.cmakeBool "WITH_BENCHMARK" false) 71 (lib.cmakeBool "WITH_OTLP_HTTP" enableHttp) 72 (lib.cmakeBool "WITH_OTLP_GRPC" enableGrpc) 73 (lib.cmakeBool "WITH_PROMETHEUS" enablePrometheus) 74 (lib.cmakeBool "WITH_ELASTICSEARCH" enableElasticSearch) 75 (lib.cmakeBool "WITH_ZIPKIN" enableZipkin) 76 (lib.cmakeFeature "OTELCPP_PROTO_PATH" "${opentelemetry-proto}") 77 ] 78 ++ lib.optionals (cxxStandard != null) [ 79 (lib.cmakeFeature "CMAKE_CXX_STANDARD" cxxStandard) 80 (lib.cmakeFeature "WITH_STL" "CXX${cxxStandard}") 81 ]; 82 83 outputs = [ 84 "out" 85 "dev" 86 ]; 87 88 postInstall = '' 89 substituteInPlace $out/lib/cmake/opentelemetry-cpp/opentelemetry-cpp*-target.cmake \ 90 --replace-quiet "\''${_IMPORT_PREFIX}/include" "$dev/include" 91 ''; 92 93 passthru.updateScript = nix-update-script { }; 94 95 meta = { 96 description = "OpenTelemetry C++ Client Library"; 97 homepage = "https://github.com/open-telemetry/opentelemetry-cpp"; 98 license = [ lib.licenses.asl20 ]; 99 maintainers = with lib.maintainers; [ jfroche ]; 100 platforms = lib.platforms.linux; 101 # https://github.com/protocolbuffers/protobuf/issues/14492 102 broken = !(stdenv.buildPlatform.canExecute stdenv.hostPlatform); 103 }; 104})