1 { lib, stdenv, fetchFromGitHub, fetchpatch, fixDarwinDylibNames, snappy, cmake
2 , static ? stdenv.hostPlatform.isStatic }:
4 stdenv.mkDerivation rec {
8 src = fetchFromGitHub {
12 sha256 = "sha256-RL+dfSFZZzWvUobSqiPbuC4nDiGzjIIukbVJZRacHbI=";
16 # Re-enable RTTI. Needed for e.g. Ceph to compile properly.
17 # See https://github.com/NixOS/nixpkgs/issues/147801,
18 # https://github.com/google/leveldb/issues/731,
19 # https://lists.ceph.io/hyperkitty/list/dev@ceph.io/thread/K4OSAA4AJS2V7FQI6GNCKCK3IRQDBQRS/.
21 url = "https://src.fedoraproject.org/rpms/leveldb/raw/e8178670c664e952fdd00f1fc6e3eb28b2c5b6a8/f/0006-revert-no-rtti.patch";
22 sha256 = "sha256-d2YAV8O+1VKu3WwgNsWw6Cxg5sUUR+xOlJtA7pTcigQ=";
26 outputs = [ "out" "dev" ];
28 buildInputs = [ snappy ];
30 nativeBuildInputs = lib.optional stdenv.isDarwin fixDarwinDylibNames ++ [ cmake ];
34 buildFlags = [ "all" ];
36 # NOTE: disabling tests due to gtest issue
38 "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}"
39 "-DLEVELDB_BUILD_TESTS=OFF"
40 "-DLEVELDB_BUILD_BENCHMARKS=OFF"
44 substituteInPlace "$out"/lib/cmake/leveldb/leveldbTargets.cmake \
45 --replace 'INTERFACE_INCLUDE_DIRECTORIES "''${_IMPORT_PREFIX}/include"' 'INTERFACE_INCLUDE_DIRECTORIES "'$dev'"'
46 mkdir -p $dev/lib/pkgconfig
47 cat <<EOF > $dev/lib/pkgconfig/leveldb.pc
49 Description: Fast and lightweight key/value database library by Google.
51 Libs: -L$out/lib -lleveldb
52 Cflags: -I$dev/include
57 homepage = "https://github.com/google/leveldb";
58 description = "Fast and lightweight key/value database library by Google";
59 license = licenses.bsd3;
60 platforms = platforms.all;