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