acr-cli: init at 0.14 (#359508)
[NixPkgs.git] / pkgs / by-name / ro / rocksdb / package.nix
blobc08f38accaf052b3862deadae27b2abed23c3b4a
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , cmake
5 , ninja
6 , bzip2
7 , lz4
8 , snappy
9 , zlib
10 , zstd
11 , windows
12 , enableJemalloc ? false
13 , jemalloc
14 , enableLiburing ? stdenv.hostPlatform.isLinux
15 , liburing
16 , enableShared ? !stdenv.hostPlatform.isStatic
17 , sse42Support ? stdenv.hostPlatform.sse4_2Support
20 stdenv.mkDerivation (finalAttrs: {
21   pname = "rocksdb";
22   version = "9.7.3";
24   src = fetchFromGitHub {
25     owner = "facebook";
26     repo = "rocksdb";
27     rev = "v${finalAttrs.version}";
28     hash = "sha256-HeC7m9ZK7SIU7adkQEurzHf+MY7AiEwXZQaz9uZZncU=";
29   };
31   patches = lib.optional (lib.versionAtLeast finalAttrs.version "6.29.3" && enableLiburing) ./fix-findliburing.patch;
33   nativeBuildInputs = [ cmake ninja ];
35   propagatedBuildInputs = [ bzip2 lz4 snappy zlib zstd ];
37   buildInputs = lib.optional enableJemalloc jemalloc
38     ++ lib.optional enableLiburing liburing
39     ++ lib.optional stdenv.hostPlatform.isMinGW windows.mingw_w64_pthreads;
41   outputs = [
42     "out"
43     "tools"
44   ];
46  env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [
47    "-faligned-allocation"
48  ]);
50   cmakeFlags = [
51     "-DPORTABLE=1"
52     "-DWITH_JEMALLOC=${if enableJemalloc then "1" else "0"}"
53     "-DWITH_LIBURING=${if enableLiburing then "1" else "0"}"
54     "-DWITH_JNI=0"
55     "-DWITH_BENCHMARK_TOOLS=0"
56     "-DWITH_TESTS=1"
57     "-DWITH_TOOLS=0"
58     "-DWITH_CORE_TOOLS=1"
59     "-DWITH_BZ2=1"
60     "-DWITH_LZ4=1"
61     "-DWITH_SNAPPY=1"
62     "-DWITH_ZLIB=1"
63     "-DWITH_ZSTD=1"
64     "-DWITH_GFLAGS=0"
65     "-DUSE_RTTI=1"
66     "-DROCKSDB_INSTALL_ON_WINDOWS=YES" # harmless elsewhere
67     (lib.optional sse42Support "-DFORCE_SSE42=1")
68     "-DFAIL_ON_WARNINGS=NO"
69   ] ++ lib.optional (!enableShared) "-DROCKSDB_BUILD_SHARED=0";
71   # otherwise "cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]"
72   hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "format";
74   postPatch = lib.optionalString (lib.versionOlder finalAttrs.version "8") ''
75     # Fix gcc-13 build failures due to missing <cstdint> and
76     # <system_error> includes, fixed upstyream sice 8.x
77     sed -e '1i #include <cstdint>' -i db/compaction/compaction_iteration_stats.h
78     sed -e '1i #include <cstdint>' -i table/block_based/data_block_hash_index.h
79     sed -e '1i #include <cstdint>' -i util/string_util.h
80     sed -e '1i #include <cstdint>' -i include/rocksdb/utilities/checkpoint.h
81   '' + lib.optionalString (lib.versionOlder finalAttrs.version "7") ''
82     # Fix gcc-13 build failures due to missing <cstdint> and
83     # <system_error> includes, fixed upstyream sice 7.x
84     sed -e '1i #include <system_error>' -i third-party/folly/folly/synchronization/detail/ProxyLockable-inl.h
85   '';
87   preInstall = ''
88     mkdir -p $tools/bin
89     cp tools/{ldb,sst_dump}${stdenv.hostPlatform.extensions.executable} $tools/bin/
90   '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
91     ls -1 $tools/bin/* | xargs -I{} install_name_tool -change "@rpath/librocksdb.${lib.versions.major finalAttrs.version}.dylib" $out/lib/librocksdb.dylib {}
92   '' + lib.optionalString (stdenv.hostPlatform.isLinux && enableShared) ''
93     ls -1 $tools/bin/* | xargs -I{} patchelf --set-rpath $out/lib:${lib.getLib stdenv.cc.cc}/lib {}
94   '';
96   # Old version doesn't ship the .pc file, new version puts wrong paths in there.
97   postFixup = ''
98     if [ -f "$out"/lib/pkgconfig/rocksdb.pc ]; then
99       substituteInPlace "$out"/lib/pkgconfig/rocksdb.pc \
100         --replace '="''${prefix}//' '="/'
101     fi
102   '';
104   meta = with lib; {
105     homepage = "https://rocksdb.org";
106     description = "Library that provides an embeddable, persistent key-value store for fast storage";
107     changelog = "https://github.com/facebook/rocksdb/raw/v${finalAttrs.version}/HISTORY.md";
108     license = licenses.asl20;
109     platforms = platforms.all;
110     maintainers = with maintainers; [ adev magenbluten ];
111   };