Skip to content

Commit b51e704

Browse files
committedOct 6, 2024
redis: refactor
- use `fetchFromGitHub` instead of downloading from redis.io - use `fetchpatch2` instead of `fetchurl` and `fetchpatch` - use `optional` instead of `optionals` in several places - remove `with lib;` - enable `tlsSupport` by default - format with `nixfmt-rfc-style` - remove `preBuild` which does not have any motivation behind - add `which` and `python3` to `nativeBuildInputs`
1 parent 35cd37c commit b51e704

File tree

1 file changed

+66
-40
lines changed

1 file changed

+66
-40
lines changed
 

‎pkgs/by-name/re/redis/package.nix

+66-40
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,72 @@
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
6-
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
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
fetchpatch2,
6+
lua,
7+
jemalloc,
8+
pkg-config,
9+
nixosTests,
10+
tcl,
11+
which,
12+
ps,
13+
getconf,
14+
systemd,
15+
openssl,
16+
python3,
17+
18+
withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
19+
tlsSupport ? true,
20+
# Using system jemalloc fixes cross-compilation and various setups.
21+
# However the experimental 'active defragmentation' feature of redis requires
22+
# their custom patched version of jemalloc.
23+
useSystemJemalloc ? true,
1124
}:
1225

1326
stdenv.mkDerivation (finalAttrs: {
1427
pname = "redis";
1528
version = "7.2.5";
1629

17-
src = fetchurl {
18-
url = "https://download.redis.io/releases/redis-${finalAttrs.version}.tar.gz";
19-
hash = "sha256-WYEXlwb4OR8DvpHZUayvrtqRr3+sVr7/snAZYxA+Qj0=";
30+
src = fetchFromGitHub {
31+
owner = "redis";
32+
repo = "redis";
33+
rev = finalAttrs.version;
34+
hash = "sha256-CHtCtyy/dzyXwwLKVqOCV9SPTybYGbSTWHTaiPGAVIQ=";
2035
};
2136

22-
patches = [
23-
# fixes: make test [exception]: Executing test client: permission denied
24-
# https://github.com/redis/redis/issues/12792
25-
(fetchpatch {
26-
url = "https://github.com/redis/redis/pull/12887.diff";
27-
hash = "sha256-VZEMShW7Ckn5hLJHffQvE94Uly41WZW1bwvxny+Y3W8=";
28-
})
29-
] ++ lib.optionals useSystemJemalloc [
30-
# use system jemalloc
31-
(fetchurl {
37+
patches =
38+
[
39+
# fixes: make test [exception]: Executing test client: permission denied
40+
# https://github.com/redis/redis/issues/12792
41+
(fetchpatch2 {
42+
url = "https://github.com/redis/redis/pull/12887.diff";
43+
hash = "sha256-cv+EcVTz8j93E4ON0NpxwQiEPmt6/cWrmAsonvvYVfQ=";
44+
})
45+
]
46+
++ lib.optional useSystemJemalloc (fetchpatch2 {
3247
url = "https://gitlab.archlinux.org/archlinux/packaging/packages/redis/-/raw/102cc861713c796756abd541bf341a4512eb06e6/redis-5.0-use-system-jemalloc.patch";
33-
hash = "sha256-VPRfoSnctkkkzLrXEWQX3Lh5HmZaCXoJafyOG007KzM=";
34-
})
35-
];
48+
hash = "sha256-A9qp+PWQRuNy/xmv9KLM7/XAyL7Tzkyn0scpVCGngcc=";
49+
});
3650

37-
nativeBuildInputs = [ pkg-config ];
51+
nativeBuildInputs = [
52+
pkg-config
53+
which
54+
python3
55+
];
3856

39-
buildInputs = [ lua ]
57+
buildInputs =
58+
[ lua ]
4059
++ lib.optional useSystemJemalloc jemalloc
4160
++ lib.optional withSystemd systemd
42-
++ lib.optionals tlsSupport [ openssl ];
43-
44-
preBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
45-
substituteInPlace src/Makefile --replace "-flto" ""
46-
'';
61+
++ lib.optional tlsSupport openssl;
4762

4863
# 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" ]
64+
makeFlags =
65+
[ "PREFIX=${placeholder "out"}" ]
66+
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
67+
"AR=${stdenv.cc.targetPrefix}ar"
68+
"RANLIB=${stdenv.cc.targetPrefix}ranlib"
69+
]
5170
++ lib.optionals withSystemd [ "USE_SYSTEMD=yes" ]
5271
++ lib.optionals tlsSupport [ "BUILD_TLS=yes" ];
5372

@@ -59,7 +78,11 @@ stdenv.mkDerivation (finalAttrs: {
5978

6079
# darwin currently lacks a pure `pgrep` which is extensively used here
6180
doCheck = !stdenv.hostPlatform.isDarwin;
62-
nativeCheckInputs = [ which tcl ps ] ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ];
81+
nativeCheckInputs = [
82+
which
83+
tcl
84+
ps
85+
] ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ];
6386
checkPhase = ''
6487
runHook preCheck
6588
@@ -87,13 +110,16 @@ stdenv.mkDerivation (finalAttrs: {
87110
passthru.tests.redis = nixosTests.redis;
88111
passthru.serverBin = "redis-server";
89112

90-
meta = with lib; {
113+
meta = {
91114
homepage = "https://redis.io";
92115
description = "Open source, advanced key-value store";
93-
license = licenses.bsd3;
94-
platforms = platforms.all;
116+
license = lib.licenses.bsd3;
117+
platforms = lib.platforms.all;
95118
changelog = "https://github.com/redis/redis/raw/${finalAttrs.version}/00-RELEASENOTES";
96-
maintainers = with maintainers; [ berdario globin ];
119+
maintainers = with lib.maintainers; [
120+
berdario
121+
globin
122+
];
97123
mainProgram = "redis-cli";
98124
};
99125
})

0 commit comments

Comments
 (0)
Failed to load comments.