at 24.05-pre 101 lines 3.0 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, fetchpatch 5, cmake 6, ninja 7, bzip2 8, lz4 9, snappy 10, zlib 11, zstd 12, windows 13, enableJemalloc ? false 14, jemalloc 15, enableShared ? !stdenv.hostPlatform.isStatic 16, sse42Support ? stdenv.hostPlatform.sse4_2Support 17}: 18 19stdenv.mkDerivation rec { 20 pname = "rocksdb"; 21 version = "8.3.2"; 22 23 src = fetchFromGitHub { 24 owner = "facebook"; 25 repo = pname; 26 rev = "v${version}"; 27 hash = "sha256-mfIRQ8nkUbZ3Bugy3NAvOhcfzFY84J2kBUIUBcQ2/Qg="; 28 }; 29 30 nativeBuildInputs = [ cmake ninja ]; 31 32 propagatedBuildInputs = [ bzip2 lz4 snappy zlib zstd ]; 33 34 buildInputs = lib.optional enableJemalloc jemalloc 35 ++ lib.optional stdenv.hostPlatform.isMinGW windows.mingw_w64_pthreads; 36 37 outputs = [ 38 "out" 39 "tools" 40 ]; 41 42 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ 43 "-Wno-error=deprecated-copy" 44 "-Wno-error=pessimizing-move" 45 # Needed with GCC 12 46 "-Wno-error=format-truncation" 47 "-Wno-error=maybe-uninitialized" 48 ] ++ lib.optionals stdenv.cc.isClang [ 49 "-Wno-error=unused-private-field" 50 "-faligned-allocation" 51 ]); 52 53 cmakeFlags = [ 54 "-DPORTABLE=1" 55 "-DWITH_JEMALLOC=${if enableJemalloc then "1" else "0"}" 56 "-DWITH_JNI=0" 57 "-DWITH_BENCHMARK_TOOLS=0" 58 "-DWITH_TESTS=1" 59 "-DWITH_TOOLS=0" 60 "-DWITH_CORE_TOOLS=1" 61 "-DWITH_BZ2=1" 62 "-DWITH_LZ4=1" 63 "-DWITH_SNAPPY=1" 64 "-DWITH_ZLIB=1" 65 "-DWITH_ZSTD=1" 66 "-DWITH_GFLAGS=0" 67 "-DUSE_RTTI=1" 68 "-DROCKSDB_INSTALL_ON_WINDOWS=YES" # harmless elsewhere 69 (lib.optional sse42Support "-DFORCE_SSE42=1") 70 "-DFAIL_ON_WARNINGS=${if stdenv.hostPlatform.isMinGW then "NO" else "YES"}" 71 ] ++ lib.optional (!enableShared) "-DROCKSDB_BUILD_SHARED=0"; 72 73 # otherwise "cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]" 74 hardeningDisable = lib.optional stdenv.hostPlatform.isWindows "format"; 75 76 preInstall = '' 77 mkdir -p $tools/bin 78 cp tools/{ldb,sst_dump}${stdenv.hostPlatform.extensions.executable} $tools/bin/ 79 '' + lib.optionalString stdenv.isDarwin '' 80 ls -1 $tools/bin/* | xargs -I{} install_name_tool -change "@rpath/librocksdb.${lib.versions.major version}.dylib" $out/lib/librocksdb.dylib {} 81 '' + lib.optionalString (stdenv.isLinux && enableShared) '' 82 ls -1 $tools/bin/* | xargs -I{} patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib {} 83 ''; 84 85 # Old version doesn't ship the .pc file, new version puts wrong paths in there. 86 postFixup = '' 87 if [ -f "$out"/lib/pkgconfig/rocksdb.pc ]; then 88 substituteInPlace "$out"/lib/pkgconfig/rocksdb.pc \ 89 --replace '="''${prefix}//' '="/' 90 fi 91 ''; 92 93 meta = with lib; { 94 homepage = "https://rocksdb.org"; 95 description = "A library that provides an embeddable, persistent key-value store for fast storage"; 96 changelog = "https://github.com/facebook/rocksdb/raw/v${version}/HISTORY.md"; 97 license = licenses.asl20; 98 platforms = platforms.all; 99 maintainers = with maintainers; [ adev magenbluten ]; 100 }; 101}