2023-03-15 16:39:30 +00:00
|
|
|
{ lib, stdenv, fetchurl, fetchpatch, lua, pkg-config, nixosTests
|
2023-01-11 07:51:40 +00:00
|
|
|
, tcl, which, ps, getconf
|
2023-02-02 18:25:31 +00:00
|
|
|
, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
|
2021-09-23 15:35:13 +00:00
|
|
|
# dependency ordering is broken at the moment when building with openssl
|
|
|
|
, tlsSupport ? !stdenv.hostPlatform.isStatic, openssl
|
2021-01-15 22:18:51 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "redis";
|
2023-04-29 16:46:19 +00:00
|
|
|
version = "7.0.11";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-03-09 03:18:52 +00:00
|
|
|
url = "https://download.redis.io/releases/${pname}-${version}.tar.gz";
|
2023-04-29 16:46:19 +00:00
|
|
|
hash = "sha256-ziUNH7oELGE944oV1AiJt498ttVGGifjUBe6ObByIeM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
patches = [
|
|
|
|
# Fix flaky test tests/unit/memefficiency.tcl
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/redis/redis/commit/bfe50a30edff6837897964ac3374c082b0d9e5da.patch";
|
|
|
|
sha256 = "sha256-0GMiygbO7LbL1rnuOByOJYE2BKUSI+yy6YH781E2zBw=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2021-01-15 22:18:51 +00:00
|
|
|
|
|
|
|
buildInputs = [ lua ]
|
2021-04-19 03:05:28 +00:00
|
|
|
++ lib.optional withSystemd systemd
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optionals tlsSupport [ openssl ];
|
2020-04-24 23:36:52 +00:00
|
|
|
# More cross-compiling fixes.
|
|
|
|
# Note: this enables libc malloc as a temporary fix for cross-compiling.
|
|
|
|
# Due to hardcoded configure flags in jemalloc, we can't cross-compile vendored jemalloc properly, and so we're forced to use libc allocator.
|
|
|
|
# It's weird that the build isn't failing because of failure to compile dependencies, it's from failure to link them!
|
2022-09-30 11:47:45 +00:00
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ]
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "AR=${stdenv.cc.targetPrefix}ar" "RANLIB=${stdenv.cc.targetPrefix}ranlib" "MALLOC=libc" ]
|
2022-10-30 15:09:59 +00:00
|
|
|
++ lib.optionals withSystemd [ "USE_SYSTEMD=yes" ]
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optionals tlsSupport [ "BUILD_TLS=yes" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
hardeningEnable = [ "pie" ];
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ "-std=c11" ]);
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# darwin currently lacks a pure `pgrep` which is extensively used here
|
|
|
|
doCheck = !stdenv.isDarwin;
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ which tcl ps ] ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ];
|
2022-04-15 01:41:22 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# disable test "Connect multiple replicas at the same time": even
|
|
|
|
# upstream find this test too timing-sensitive
|
|
|
|
substituteInPlace tests/integration/replication.tcl \
|
|
|
|
--replace 'foreach mdl {no yes}' 'foreach mdl {}'
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
substituteInPlace tests/support/server.tcl \
|
|
|
|
--replace 'exec /usr/bin/env' 'exec env'
|
|
|
|
|
|
|
|
sed -i '/^proc wait_load_handlers_disconnected/{n ; s/wait_for_condition 50 100/wait_for_condition 50 500/; }' \
|
|
|
|
tests/support/util.tcl
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
./runtest \
|
|
|
|
--no-latency \
|
|
|
|
--timeout 2000 \
|
|
|
|
--clients $NIX_BUILD_CORES \
|
|
|
|
--tags -leaks \
|
|
|
|
--skipunit integration/failover # flaky and slow
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
passthru.tests.redis = nixosTests.redis;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://redis.io";
|
|
|
|
description = "An open source, advanced key-value store";
|
|
|
|
license = licenses.bsd3;
|
2021-03-09 03:18:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
changelog = "https://github.com/redis/redis/raw/${version}/00-RELEASENOTES";
|
|
|
|
maintainers = with maintainers; [ berdario globin marsam ];
|
2021-10-04 12:37:57 +00:00
|
|
|
mainProgram = "redis-cli";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|