nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 libuuid,
6 curl,
7 pkg-config,
8 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
9 systemd,
10 tlsSupport ? !stdenv.hostPlatform.isStatic,
11 openssl,
12 jemalloc,
13 which,
14 tcl,
15 tclPackages,
16 ps,
17 getconf,
18 nixosTests,
19}:
20
21stdenv.mkDerivation (finalAttrs: {
22 pname = "keydb";
23 version = "6.3.4";
24
25 src = fetchFromGitHub {
26 owner = "snapchat";
27 repo = "keydb";
28 rev = "v${finalAttrs.version}";
29 hash = "sha256-j6qgK6P3Fv+b6k9jwKQ5zW7XLkKbXXcmHKBCQYvwEIU=";
30 };
31
32 postPatch = ''
33 substituteInPlace deps/lua/src/Makefile \
34 --replace-fail "ar rcu" "${stdenv.cc.targetPrefix}ar rcu"
35 substituteInPlace src/Makefile \
36 --replace-fail "as --64 -g" "${stdenv.cc.targetPrefix}as --64 -g"
37 '';
38
39 nativeBuildInputs = [ pkg-config ];
40 buildInputs = [
41 jemalloc
42 curl
43 libuuid
44 ]
45 ++ lib.optionals tlsSupport [ openssl ]
46 ++ lib.optionals withSystemd [ systemd ];
47
48 makeFlags = [
49 "PREFIX=${placeholder "out"}"
50 "AR=${stdenv.cc.targetPrefix}ar"
51 "RANLIB=${stdenv.cc.targetPrefix}ranlib"
52 "USEASM=${if stdenv.hostPlatform.isx86_64 then "true" else "false"}"
53 ]
54 ++ lib.optionals (!tlsSupport) [ "BUILD_TLS=no" ]
55 ++ lib.optionals withSystemd [ "USE_SYSTEMD=yes" ]
56 ++ lib.optionals (!stdenv.hostPlatform.isx86_64) [ "MALLOC=libc" ];
57
58 enableParallelBuilding = true;
59
60 hardeningEnable = lib.optionals (!stdenv.hostPlatform.isDarwin) [ "pie" ];
61
62 # darwin currently lacks a pure `pgrep` which is extensively used here
63 doCheck = !stdenv.hostPlatform.isDarwin;
64 nativeCheckInputs = [
65 which
66 tcl
67 ps
68 ]
69 ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ]
70 ++ lib.optionals tlsSupport [ tclPackages.tcltls ];
71 checkPhase = ''
72 runHook preCheck
73
74 # disable test "Connect multiple replicas at the same time": even
75 # upstream find this test too timing-sensitive
76 substituteInPlace tests/integration/replication.tcl \
77 --replace-fail 'foreach mdl {no yes}' 'foreach mdl {}'
78
79 substituteInPlace tests/support/server.tcl \
80 --replace-fail 'exec /usr/bin/env' 'exec env'
81
82 sed -i '/^proc wait_load_handlers_disconnected/{n ; s/wait_for_condition 50 100/wait_for_condition 50 500/; }' \
83 tests/support/util.tcl
84
85 patchShebangs ./utils/gen-test-certs.sh
86 ${if tlsSupport then "./utils/gen-test-certs.sh" else ""}
87 ./runtest --clients $NIX_BUILD_CORES ${
88 lib.escapeShellArgs (
89 [
90 "--no-latency"
91 "--timeout"
92 "2000"
93 "--tags"
94 "-leaks"
95 ]
96 ++ lib.optional tlsSupport "--tls"
97 # skips flaky test on x86_64
98 ++ lib.optionals stdenv.hostPlatform.isx86_64 [
99 "--skiptest"
100 "Active defrag edge case"
101 ]
102 )
103 }
104
105 runHook postCheck
106 '';
107
108 passthru.tests.redis = nixosTests.redis;
109 passthru.serverBin = "keydb-server";
110
111 meta = {
112 homepage = "https://keydb.dev";
113 description = "Multithreaded Fork of Redis";
114 license = lib.licenses.bsd3;
115 platforms = lib.platforms.all;
116 changelog = "https://github.com/Snapchat/KeyDB/raw/v${finalAttrs.version}/00-RELEASENOTES";
117 teams = [ lib.teams.helsinki-systems ];
118 mainProgram = "keydb-cli";
119 };
120})