2023-02-16 17:41:37 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-07-18 16:06:22 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
|
|
|
, cmake
|
|
|
|
, ninja
|
|
|
|
, bzip2
|
|
|
|
, lz4
|
|
|
|
, snappy
|
|
|
|
, zlib
|
|
|
|
, zstd
|
2023-02-16 17:41:37 +00:00
|
|
|
, windows
|
|
|
|
, enableJemalloc ? false
|
|
|
|
, jemalloc
|
2021-01-05 17:05:55 +00:00
|
|
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
2022-11-27 09:42:12 +00:00
|
|
|
, sse42Support ? stdenv.hostPlatform.sse4_2Support
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "rocksdb";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "8.3.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "facebook";
|
2024-01-02 11:29:13 +00:00
|
|
|
repo = finalAttrs.pname;
|
|
|
|
rev = "v${finalAttrs.version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-mfIRQ8nkUbZ3Bugy3NAvOhcfzFY84J2kBUIUBcQ2/Qg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2020-10-27 00:29:36 +00:00
|
|
|
propagatedBuildInputs = [ bzip2 lz4 snappy zlib zstd ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
buildInputs = lib.optional enableJemalloc jemalloc
|
|
|
|
++ lib.optional stdenv.hostPlatform.isMinGW windows.mingw_w64_pthreads;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"tools"
|
|
|
|
];
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [
|
|
|
|
"-faligned-allocation"
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DPORTABLE=1"
|
2020-10-27 00:29:36 +00:00
|
|
|
"-DWITH_JEMALLOC=${if enableJemalloc then "1" else "0"}"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DWITH_JNI=0"
|
2020-07-18 16:06:22 +00:00
|
|
|
"-DWITH_BENCHMARK_TOOLS=0"
|
|
|
|
"-DWITH_TESTS=1"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DWITH_TOOLS=0"
|
2022-12-28 21:21:41 +00:00
|
|
|
"-DWITH_CORE_TOOLS=1"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DWITH_BZ2=1"
|
|
|
|
"-DWITH_LZ4=1"
|
|
|
|
"-DWITH_SNAPPY=1"
|
|
|
|
"-DWITH_ZLIB=1"
|
|
|
|
"-DWITH_ZSTD=1"
|
|
|
|
"-DWITH_GFLAGS=0"
|
|
|
|
"-DUSE_RTTI=1"
|
|
|
|
"-DROCKSDB_INSTALL_ON_WINDOWS=YES" # harmless elsewhere
|
2022-11-27 09:42:12 +00:00
|
|
|
(lib.optional sse42Support "-DFORCE_SSE42=1")
|
2024-04-21 15:54:59 +00:00
|
|
|
"-DFAIL_ON_WARNINGS=NO"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optional (!enableShared) "-DROCKSDB_BUILD_SHARED=0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# otherwise "cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]"
|
2021-02-05 17:12:51 +00:00
|
|
|
hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "format";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
postPatch = lib.optionalString (lib.versionOlder finalAttrs.version "8") ''
|
|
|
|
# Fix gcc-13 build failures due to missing <cstdint> and
|
|
|
|
# <system_error> includes, fixed upstyream sice 8.x
|
|
|
|
sed -e '1i #include <cstdint>' -i db/compaction/compaction_iteration_stats.h
|
|
|
|
sed -e '1i #include <cstdint>' -i table/block_based/data_block_hash_index.h
|
|
|
|
sed -e '1i #include <cstdint>' -i util/string_util.h
|
|
|
|
sed -e '1i #include <cstdint>' -i include/rocksdb/utilities/checkpoint.h
|
|
|
|
'' + lib.optionalString (lib.versionOlder finalAttrs.version "7") ''
|
|
|
|
# Fix gcc-13 build failures due to missing <cstdint> and
|
|
|
|
# <system_error> includes, fixed upstyream sice 7.x
|
|
|
|
sed -e '1i #include <system_error>' -i third-party/folly/folly/synchronization/detail/ProxyLockable-inl.h
|
|
|
|
'';
|
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
preInstall = ''
|
|
|
|
mkdir -p $tools/bin
|
2023-02-16 17:41:37 +00:00
|
|
|
cp tools/{ldb,sst_dump}${stdenv.hostPlatform.extensions.executable} $tools/bin/
|
2022-12-28 21:21:41 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2024-01-02 11:29:13 +00:00
|
|
|
ls -1 $tools/bin/* | xargs -I{} install_name_tool -change "@rpath/librocksdb.${lib.versions.major finalAttrs.version}.dylib" $out/lib/librocksdb.dylib {}
|
2022-12-28 21:21:41 +00:00
|
|
|
'' + lib.optionalString (stdenv.isLinux && enableShared) ''
|
|
|
|
ls -1 $tools/bin/* | xargs -I{} patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib {}
|
|
|
|
'';
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
# Old version doesn't ship the .pc file, new version puts wrong paths in there.
|
|
|
|
postFixup = ''
|
|
|
|
if [ -f "$out"/lib/pkgconfig/rocksdb.pc ]; then
|
|
|
|
substituteInPlace "$out"/lib/pkgconfig/rocksdb.pc \
|
|
|
|
--replace '="''${prefix}//' '="/'
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://rocksdb.org";
|
|
|
|
description = "A library that provides an embeddable, persistent key-value store for fast storage";
|
2024-01-02 11:29:13 +00:00
|
|
|
changelog = "https://github.com/facebook/rocksdb/raw/v${finalAttrs.version}/HISTORY.md";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
2021-08-08 23:34:03 +00:00
|
|
|
platforms = platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ adev magenbluten ];
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
})
|