Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 94 lines 2.4 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchFromGitHub, 5 perl, 6 which, 7 rdkafka, 8 jansson, 9 curl, 10 avro-c, 11 avro-cpp, 12 nix-update-script, 13}: 14 15stdenv.mkDerivation rec { 16 pname = "libserdes"; 17 version = "7.9.2"; 18 19 src = fetchFromGitHub { 20 owner = "confluentinc"; 21 repo = "libserdes"; 22 rev = "v${version}"; 23 hash = "sha256-rg4SWa9nIDT6JrnnCDwdiFE1cvpUn0HWHn+bPkXMHQ4="; 24 }; 25 26 outputs = [ 27 "dev" 28 "out" 29 ]; 30 31 nativeBuildInputs = [ 32 perl 33 which 34 ]; 35 36 buildInputs = [ 37 rdkafka 38 jansson 39 curl 40 avro-c 41 avro-cpp 42 ]; 43 44 configureFlags = [ 45 # avro-cpp public headers use at least C++17 features, but libserdes configure scripts 46 # basically cap it at C++11. It's really unfortunate that we have to patch the configure scripts for this, 47 # but this seems to be the most sensible way. 48 # - NIX_CFLAGS_COMPILE - fails because of -Werror in compiler checks since --std=... has no effect for C compilers. 49 # - CXXFLAGS without patching configure.self does nothing, because --std=c++11 is appended to the final flags, overriding 50 # everything specified manually. 51 "--CXXFLAGS=${toString [ "--std=c++17" ]}" 52 ]; 53 54 makeFlags = [ 55 "GEN_PKG_CONFIG=y" 56 ]; 57 58 postPatch = '' 59 patchShebangs configure lds-gen.pl 60 # Don't append the standard to CXXFLAGS, since we want to set it higher for avro-cpp. 61 substituteInPlace configure.self --replace-fail \ 62 'mkl_mkvar_append CXXFLAGS CXXFLAGS "--std=c++11"' \ 63 ":" # Do nothing, we set the standard ourselves. 64 ''; 65 66 # Has a configure script but it’s not Autoconf so steal some bits from multiple-outputs.sh: 67 setOutputFlags = false; 68 69 preConfigure = '' 70 configureFlagsArray+=( 71 "--libdir=''${!outputLib}/lib" 72 "--includedir=''${!outputInclude}/include" 73 ) 74 ''; 75 76 preInstall = '' 77 installFlagsArray+=("pkgconfigdir=''${!outputDev}/lib/pkgconfig") 78 ''; 79 80 # Header files get installed with executable bit for some reason; get rid of it. 81 postInstall = '' 82 chmod -x ''${!outputInclude}/include/libserdes/*.h 83 ''; 84 85 passthru.updateScript = nix-update-script { }; 86 87 meta = with lib; { 88 description = "Schema-based serializer/deserializer C/C++ library with support for Avro and the Confluent Platform Schema Registry"; 89 homepage = "https://github.com/confluentinc/libserdes"; 90 license = licenses.asl20; 91 maintainers = with maintainers; [ liff ]; 92 platforms = platforms.all; 93 }; 94}