audiobookshelf: 2.18.1 -> 2.19.0 (#378967)
[NixPkgs.git] / pkgs / by-name / va / valkey / package.nix
blob463cec95f523c3682898520675558d02ad144c54
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   lua,
6   jemalloc,
7   pkg-config,
8   tcl,
9   which,
10   ps,
11   getconf,
12   withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
13   systemd,
14   # dependency ordering is broken at the moment when building with openssl
15   tlsSupport ? !stdenv.hostPlatform.isStatic,
16   openssl,
18   # Using system jemalloc fixes cross-compilation and various setups.
19   # However the experimental 'active defragmentation' feature of valkey requires
20   # their custom patched version of jemalloc.
21   useSystemJemalloc ? true,
24 stdenv.mkDerivation (finalAttrs: {
25   pname = "valkey";
26   version = "8.0.2";
28   src = fetchFromGitHub {
29     owner = "valkey-io";
30     repo = "valkey";
31     rev = finalAttrs.version;
32     hash = "sha256-05EuPjVokzfJxhrnvFHD7prwt5y7gPxemeDIkLML7lw=";
33   };
35   patches = lib.optional useSystemJemalloc ./use_system_jemalloc.patch;
37   nativeBuildInputs = [ pkg-config ];
39   buildInputs =
40     [ lua ]
41     ++ lib.optional useSystemJemalloc jemalloc
42     ++ lib.optional withSystemd systemd
43     ++ lib.optional tlsSupport openssl;
45   strictDeps = true;
47   preBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
48     substituteInPlace src/Makefile --replace-fail "-flto" ""
49   '';
51   # More cross-compiling fixes.
52   makeFlags =
53     [ "PREFIX=${placeholder "out"}" ]
54     ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
55       "AR=${stdenv.cc.targetPrefix}ar"
56       "RANLIB=${stdenv.cc.targetPrefix}ranlib"
57     ]
58     ++ lib.optionals withSystemd [ "USE_SYSTEMD=yes" ]
59     ++ lib.optionals tlsSupport [ "BUILD_TLS=yes" ];
61   enableParallelBuilding = true;
63   hardeningEnable = lib.optionals (!stdenv.hostPlatform.isDarwin) [ "pie" ];
65   env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ "-std=c11" ]);
67   # darwin currently lacks a pure `pgrep` which is extensively used here
68   doCheck = !stdenv.hostPlatform.isDarwin;
69   nativeCheckInputs = [
70     which
71     tcl
72     ps
73   ] ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ];
74   checkPhase = ''
75     runHook preCheck
77     # disable test "Connect multiple replicas at the same time": even
78     # upstream find this test too timing-sensitive
79     substituteInPlace tests/integration/replication.tcl \
80       --replace-fail 'foreach mdl {no yes} dualchannel {no yes}' 'foreach mdl {} dualchannel {}'
82     substituteInPlace tests/support/server.tcl \
83       --replace-fail 'exec /usr/bin/env' 'exec env'
85     sed -i '/^proc wait_load_handlers_disconnected/{n ; s/wait_for_condition 50 100/wait_for_condition 50 500/; }' \
86       tests/support/util.tcl
88     ./runtest \
89       --no-latency \
90       --timeout 2000 \
91       --clients $NIX_BUILD_CORES \
92       --tags -leaks \
93       --skipunit integration/failover # flaky and slow
95     runHook postCheck
96   '';
98   meta = with lib; {
99     homepage = "https://valkey.io/";
100     description = "High-performance data structure server that primarily serves key/value workloads";
101     license = licenses.bsd3;
102     platforms = platforms.all;
103     maintainers = with maintainers; [ rucadi ];
104     changelog = "https://github.com/valkey-io/valkey/releases/tag/${finalAttrs.version}";
105     mainProgram = "valkey-cli";
106   };