python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / leveldb / default.nix
blob8cac5df55ea2058fc28866a654be1b598f3905ff
1 { lib, stdenv, fetchFromGitHub, fetchpatch, fixDarwinDylibNames, snappy, cmake
2 , static ? stdenv.hostPlatform.isStatic }:
4 stdenv.mkDerivation rec {
5   pname = "leveldb";
6   version = "1.23";
8   src = fetchFromGitHub {
9     owner = "google";
10     repo = "leveldb";
11     rev = "${version}";
12     sha256 = "sha256-RL+dfSFZZzWvUobSqiPbuC4nDiGzjIIukbVJZRacHbI=";
13   };
15   patches = [
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/.
20     (fetchpatch {
21       url = "https://src.fedoraproject.org/rpms/leveldb/raw/e8178670c664e952fdd00f1fc6e3eb28b2c5b6a8/f/0006-revert-no-rtti.patch";
22       sha256 = "sha256-d2YAV8O+1VKu3WwgNsWw6Cxg5sUUR+xOlJtA7pTcigQ=";
23     })
24   ];
26   outputs = [ "out" "dev" ];
28   buildInputs = [ snappy ];
30   nativeBuildInputs = lib.optional stdenv.isDarwin fixDarwinDylibNames ++ [ cmake ];
32   doCheck = true;
34   buildFlags = [ "all" ];
36   # NOTE: disabling tests due to gtest issue
37   cmakeFlags = [
38     "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}"
39     "-DLEVELDB_BUILD_TESTS=OFF"
40     "-DLEVELDB_BUILD_BENCHMARKS=OFF"
41   ];
43   postInstall = ''
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
48       Name: leveldb
49       Description: Fast and lightweight key/value database library by Google.
50       Version: ${version}
51       Libs: -L$out/lib -lleveldb
52       Cflags: -I$dev/include
53     EOF
54   '';
56   meta = with lib; {
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;
61   };