summary refs log tree commit diff
path: root/pkgs/development/libraries/rocksdb/default.nix
blob: c082d06eddd5c1d9be42aebb07595cd1b51db442 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ stdenv
, fetchFromGitHub
, fixDarwinDylibNames
, which, perl

# Optional Arguments
, snappy ? null, google-gflags ? null, zlib ? null, bzip2 ? null, lz4 ? null
, numactl ? null

# Malloc implementation
, jemalloc ? null, gperftools ? null

, enableLite ? false
}:

let
  malloc = if jemalloc != null then jemalloc else gperftools;
in
stdenv.mkDerivation rec {
  name = "rocksdb-${version}";
  version = "5.11.3";

  outputs = [ "dev" "out" "static" ];

  src = fetchFromGitHub {
    owner = "facebook";
    repo = "rocksdb";
    rev = "v${version}";
    sha256 = "15x2r7aib1xinwcchl32wghs8g96k4q5xgv6z97mxgp35475x01p";
  };
  
  nativeBuildInputs = [ which perl ];
  buildInputs = [ snappy google-gflags zlib bzip2 lz4 malloc fixDarwinDylibNames ];

  postPatch = ''
    # Hack to fix typos
    sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform
  '';

  # Environment vars used for building certain configurations
  PORTABLE = "1";
  USE_SSE = "1";
  CMAKE_CXX_FLAGS = "-std=gnu++11";
  JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc";

  ${if enableLite then "LIBNAME" else null} = "librocksdb_lite";
  ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1";
  
  buildAndInstallFlags = [
    "USE_RTTI=1"
    "DEBUG_LEVEL=0"
    "DISABLE_WARNING_AS_ERROR=1"     
  ];

  buildFlags = buildAndInstallFlags ++ [
    "shared_lib"
    "static_lib"
  ];

  installFlags = buildAndInstallFlags ++ [
    "INSTALL_PATH=\${out}"
    "install-shared"
    "install-static"
  ];

  postInstall = ''
    # Might eventually remove this when we are confident in the build process
    echo "BUILD CONFIGURATION FOR SANITY CHECKING"
    cat make_config.mk
    mkdir -pv $static/lib/
    mv -vi $out/lib/librocksdb.a $static/lib/
  '';

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    homepage = http://rocksdb.org;
    description = "A library that provides an embeddable, persistent key-value store for fast storage";
    license = licenses.bsd3;
    platforms = platforms.allBut [ "i686-linux" ];
    maintainers = with maintainers; [ adev wkennington ];
  };
}