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