Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 fetchFromGitHub,
3 fetchurl,
4 lib,
5 stdenv,
6 double-conversion,
7 gperftools,
8 mimalloc,
9 rapidjson,
10 liburing,
11 xxHash,
12 gbenchmark,
13 glog,
14 gtest,
15 jemalloc,
16 gcc-unwrapped,
17 autoconf,
18 autoconf-archive,
19 automake,
20 cmake,
21 ninja,
22 boost,
23 libunwind,
24 libtool,
25 openssl,
26}:
27
28let
29 pname = "dragonflydb";
30 version = "0.1.0";
31
32 src = fetchFromGitHub {
33 owner = pname;
34 repo = "dragonfly";
35 rev = "v${version}";
36 hash = "sha256-P6WMW/n+VezWDXGagT4B+ZYyCp8oufDV6MTrpKpLZcs=";
37 fetchSubmodules = true;
38 };
39
40 # Needed exactly 5.4.4 for patch to work
41 lua = fetchurl {
42 url = "https://github.com/lua/lua/archive/refs/tags/v5.4.4.tar.gz";
43 hash = "sha256-L/ibvqIqfIuRDWsAb1ukVZ7c9GiiVTfO35mI7ZD2tFA=";
44 };
45
46 # Needed exactly 20211102.0 for patch to work
47 abseil-cpp_202111 = fetchFromGitHub {
48 owner = "abseil";
49 repo = "abseil-cpp";
50 rev = "20211102.0";
51 sha256 = "sha256-sSXT6D4JSrk3dA7kVaxfKkzOMBpqXQb0WbMYWG+nGwk=";
52 };
53in
54stdenv.mkDerivation {
55 inherit pname version src;
56
57 postPatch = ''
58 mkdir -p ./build/{third_party,_deps}
59 ln -s ${double-conversion.src} ./build/third_party/dconv
60 ln -s ${mimalloc.src} ./build/third_party/mimalloc
61 ln -s ${rapidjson.src} ./build/third_party/rapidjson
62 ln -s ${gbenchmark.src} ./build/_deps/benchmark-src
63 ln -s ${gtest.src} ./build/_deps/gtest-src
64 cp -R --no-preserve=mode,ownership ${gperftools.src} ./build/third_party/gperf
65 cp -R --no-preserve=mode,ownership ${liburing.src} ./build/third_party/uring
66 cp -R --no-preserve=mode,ownership ${xxHash.src} ./build/third_party/xxhash
67 cp -R --no-preserve=mode,ownership ${abseil-cpp_202111} ./build/_deps/abseil_cpp-src
68 cp -R --no-preserve=mode,ownership ${glog.src} ./build/_deps/glog-src
69 chmod u+x ./build/third_party/uring/configure
70 cp ./build/third_party/xxhash/cli/xxhsum.{1,c} ./build/third_party/xxhash
71 patch -p1 -d ./build/_deps/glog-src < ${./glog.patch}
72 sed '
73 s@REPLACEJEMALLOCURL@file://${jemalloc.src}@
74 s@REPLACELUAURL@file://${lua}@
75 ' ${./fixes.patch} | patch -p1
76 '';
77
78 nativeBuildInputs = [
79 autoconf
80 autoconf-archive
81 automake
82 cmake
83 ninja
84 ];
85
86 buildInputs = [
87 boost
88 libunwind
89 libtool
90 openssl
91 ];
92
93 cmakeFlags = [
94 "-DCMAKE_AR=${gcc-unwrapped}/bin/gcc-ar"
95 "-DCMAKE_RANLIB=${gcc-unwrapped}/bin/gcc-ranlib"
96 ];
97
98 ninjaFlags = [ "dragonfly" ];
99
100 doCheck = false;
101 dontUseNinjaInstall = true;
102
103 installPhase = ''
104 runHook preInstall
105 mkdir -p $out/bin
106 cp ./dragonfly $out/bin
107 runHook postInstall
108 '';
109
110 meta = with lib; {
111 description = "Modern replacement for Redis and Memcached";
112 homepage = "https://dragonflydb.io/";
113 license = licenses.bsl11;
114 platforms = platforms.linux;
115 maintainers = with maintainers; [ yureien ];
116 };
117}