1 { lib, stdenv, fetchurl, fetchpatch, lua, jemalloc, pkg-config, nixosTests
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 redis requires
9 # their custom patched version of jemalloc.
10 , useSystemJemalloc ? true
13 stdenv.mkDerivation (finalAttrs: {
18 url = "https://download.redis.io/releases/redis-${finalAttrs.version}.tar.gz";
19 hash = "sha256-WYEXlwb4OR8DvpHZUayvrtqRr3+sVr7/snAZYxA+Qj0=";
23 # fixes: make test [exception]: Executing test client: permission denied
24 # https://github.com/redis/redis/issues/12792
26 url = "https://github.com/redis/redis/pull/12887.diff";
27 hash = "sha256-VZEMShW7Ckn5hLJHffQvE94Uly41WZW1bwvxny+Y3W8=";
29 ] ++ lib.optionals useSystemJemalloc [
32 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/redis/-/raw/102cc861713c796756abd541bf341a4512eb06e6/redis-5.0-use-system-jemalloc.patch";
33 hash = "sha256-VPRfoSnctkkkzLrXEWQX3Lh5HmZaCXoJafyOG007KzM=";
37 nativeBuildInputs = [ pkg-config ];
40 ++ lib.optional useSystemJemalloc jemalloc
41 ++ lib.optional withSystemd systemd
42 ++ lib.optionals tlsSupport [ openssl ];
44 preBuild = lib.optionalString stdenv.isDarwin ''
45 substituteInPlace src/Makefile --replace "-flto" ""
48 # More cross-compiling fixes.
49 makeFlags = [ "PREFIX=${placeholder "out"}" ]
50 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "AR=${stdenv.cc.targetPrefix}ar" "RANLIB=${stdenv.cc.targetPrefix}ranlib" ]
51 ++ lib.optionals withSystemd [ "USE_SYSTEMD=yes" ]
52 ++ lib.optionals tlsSupport [ "BUILD_TLS=yes" ];
54 enableParallelBuilding = true;
56 hardeningEnable = lib.optionals (!stdenv.isDarwin) [ "pie" ];
58 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ "-std=c11" ]);
60 # darwin currently lacks a pure `pgrep` which is extensively used here
61 doCheck = !stdenv.isDarwin;
62 nativeCheckInputs = [ which tcl ps ] ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ];
66 # disable test "Connect multiple replicas at the same time": even
67 # upstream find this test too timing-sensitive
68 substituteInPlace tests/integration/replication.tcl \
69 --replace 'foreach mdl {no yes}' 'foreach mdl {}'
71 substituteInPlace tests/support/server.tcl \
72 --replace 'exec /usr/bin/env' 'exec env'
74 sed -i '/^proc wait_load_handlers_disconnected/{n ; s/wait_for_condition 50 100/wait_for_condition 50 500/; }' \
75 tests/support/util.tcl
80 --clients $NIX_BUILD_CORES \
82 --skipunit integration/failover # flaky and slow
87 passthru.tests.redis = nixosTests.redis;
88 passthru.serverBin = "redis-server";
91 homepage = "https://redis.io";
92 description = "Open source, advanced key-value store";
93 license = licenses.bsd3;
94 platforms = platforms.all;
95 changelog = "https://github.com/redis/redis/raw/${finalAttrs.version}/00-RELEASENOTES";
96 maintainers = with maintainers; [ berdario globin ];
97 mainProgram = "redis-cli";