about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/nosql/dragonflydb/default.nix
blob: e73f00164fe9cd114fc1e19907629ee65d21d676 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{ fetchFromGitHub
, fetchurl
, lib
, stdenv
, double-conversion
, gperftools
, mimalloc
, rapidjson
, liburing
, xxHash
, gbenchmark
, glog
, gtest
, jemalloc
, gcc-unwrapped
, autoconf
, autoconf-archive
, automake
, cmake
, ninja
, boost
, libunwind
, libtool
, openssl
}:

let
  pname = "dragonflydb";
  version = "0.1.0";

  src = fetchFromGitHub {
    owner = pname;
    repo = "dragonfly";
    rev = "v${version}";
    hash = "sha256-P6WMW/n+VezWDXGagT4B+ZYyCp8oufDV6MTrpKpLZcs=";
    fetchSubmodules = true;
  };

  # Needed exactly 5.4.4 for patch to work
  lua = fetchurl {
    url = "https://github.com/lua/lua/archive/refs/tags/v5.4.4.tar.gz";
    hash = "sha256-L/ibvqIqfIuRDWsAb1ukVZ7c9GiiVTfO35mI7ZD2tFA=";
  };

  # Needed exactly 20211102.0 for patch to work
  abseil-cpp_202111 = fetchFromGitHub {
    owner = "abseil";
    repo = "abseil-cpp";
    rev = "20211102.0";
    sha256 = "sha256-sSXT6D4JSrk3dA7kVaxfKkzOMBpqXQb0WbMYWG+nGwk=";
  };
in
stdenv.mkDerivation {
  inherit pname version src;

  postPatch = ''
    mkdir -p ./build/{third_party,_deps}
    ln -s ${double-conversion.src} ./build/third_party/dconv
    ln -s ${mimalloc.src} ./build/third_party/mimalloc
    ln -s ${rapidjson.src} ./build/third_party/rapidjson
    ln -s ${gbenchmark.src} ./build/_deps/benchmark-src
    ln -s ${gtest.src} ./build/_deps/gtest-src
    cp -R --no-preserve=mode,ownership ${gperftools.src} ./build/third_party/gperf
    cp -R --no-preserve=mode,ownership ${liburing.src} ./build/third_party/uring
    cp -R --no-preserve=mode,ownership ${xxHash.src} ./build/third_party/xxhash
    cp -R --no-preserve=mode,ownership ${abseil-cpp_202111} ./build/_deps/abseil_cpp-src
    cp -R --no-preserve=mode,ownership ${glog.src} ./build/_deps/glog-src
    chmod u+x ./build/third_party/uring/configure
    cp ./build/third_party/xxhash/cli/xxhsum.{1,c} ./build/third_party/xxhash
    patch -p1 -d ./build/_deps/glog-src < ${./glog.patch}
    sed '
    s@REPLACEJEMALLOCURL@file://${jemalloc.src}@
    s@REPLACELUAURL@file://${lua}@
    ' ${./fixes.patch} | patch -p1
  '';

  nativeBuildInputs = [
    autoconf
    autoconf-archive
    automake
    cmake
    ninja
  ];

  buildInputs = [
    boost
    libunwind
    libtool
    openssl
  ];

  cmakeFlags = [
    "-DCMAKE_AR=${gcc-unwrapped}/bin/gcc-ar"
    "-DCMAKE_RANLIB=${gcc-unwrapped}/bin/gcc-ranlib"
  ];

  ninjaFlags = [ "dragonfly" ];

  doCheck = false;
  dontUseNinjaInstall = true;

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    cp ./dragonfly $out/bin
    runHook postInstall
  '';

  meta = with lib; {
    description = "A modern replacement for Redis and Memcached";
    homepage = "https://dragonflydb.io/";
    license = licenses.bsl11;
    platforms = platforms.linux;
    maintainers = with maintainers; [ yureien ];
  };
}