Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 123 lines 3.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 fetchpatch, 6 lua, 7 jemalloc, 8 pkg-config, 9 tcl, 10 which, 11 ps, 12 getconf, 13 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, 14 systemd, 15 # dependency ordering is broken at the moment when building with openssl 16 tlsSupport ? !stdenv.hostPlatform.isStatic, 17 openssl, 18 19 # Using system jemalloc fixes cross-compilation and various setups. 20 # However the experimental 'active defragmentation' feature of valkey requires 21 # their custom patched version of jemalloc. 22 useSystemJemalloc ? true, 23}: 24 25stdenv.mkDerivation (finalAttrs: { 26 pname = "valkey"; 27 version = "8.1.3"; 28 29 src = fetchFromGitHub { 30 owner = "valkey-io"; 31 repo = "valkey"; 32 rev = finalAttrs.version; 33 hash = "sha256-JFtStE1avSWGptgj9KtfAr55+J1FydEzD5plvSe2mjM="; 34 }; 35 36 patches = [ 37 # Fix tests on 8.1.3 38 # FIXME: remove for next release 39 (fetchpatch { 40 url = "https://github.com/valkey-io/valkey/commit/02d7ee08489fe34f853ffccce9057dea6f03d957.diff"; 41 hash = "sha256-/5U6HqgK4m1XQGTZchSmzl7hOBxCwL4XZVjE5QIZVjc="; 42 }) 43 ] 44 ++ lib.optional useSystemJemalloc ./use_system_jemalloc.patch; 45 46 nativeBuildInputs = [ pkg-config ]; 47 48 buildInputs = [ 49 lua 50 ] 51 ++ lib.optional useSystemJemalloc jemalloc 52 ++ lib.optional withSystemd systemd 53 ++ lib.optional tlsSupport openssl; 54 55 strictDeps = true; 56 57 preBuild = lib.optionalString stdenv.hostPlatform.isDarwin '' 58 substituteInPlace src/Makefile --replace-fail "-flto" "" 59 ''; 60 61 # More cross-compiling fixes. 62 makeFlags = [ 63 "PREFIX=${placeholder "out"}" 64 ] 65 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 66 "AR=${stdenv.cc.targetPrefix}ar" 67 "RANLIB=${stdenv.cc.targetPrefix}ranlib" 68 ] 69 ++ lib.optionals withSystemd [ "USE_SYSTEMD=yes" ] 70 ++ lib.optionals tlsSupport [ "BUILD_TLS=yes" ]; 71 72 enableParallelBuilding = true; 73 74 hardeningEnable = lib.optionals (!stdenv.hostPlatform.isDarwin) [ "pie" ]; 75 76 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [ "-std=c11" ]); 77 78 # darwin currently lacks a pure `pgrep` which is extensively used here 79 doCheck = !stdenv.hostPlatform.isDarwin; 80 nativeCheckInputs = [ 81 which 82 tcl 83 ps 84 ] 85 ++ lib.optionals stdenv.hostPlatform.isStatic [ getconf ]; 86 checkPhase = '' 87 runHook preCheck 88 89 # disable test "Connect multiple replicas at the same time": even 90 # upstream find this test too timing-sensitive 91 substituteInPlace tests/integration/replication.tcl \ 92 --replace-fail 'foreach mdl {no yes} dualchannel {no yes}' 'foreach mdl {} dualchannel {}' 93 94 substituteInPlace tests/support/server.tcl \ 95 --replace-fail 'exec /usr/bin/env' 'exec env' 96 97 sed -i '/^proc wait_load_handlers_disconnected/{n ; s/wait_for_condition 50 100/wait_for_condition 50 500/; }' \ 98 tests/support/util.tcl 99 100 # Skip some more flaky tests. 101 # Skip test requiring custom jemalloc (unit/memefficiency). 102 ./runtest \ 103 --no-latency \ 104 --timeout 2000 \ 105 --clients $NIX_BUILD_CORES \ 106 --tags -leaks \ 107 --skipunit unit/memefficiency \ 108 --skipunit integration/failover \ 109 --skipunit integration/aof-multi-part 110 111 runHook postCheck 112 ''; 113 114 meta = with lib; { 115 homepage = "https://valkey.io/"; 116 description = "High-performance data structure server that primarily serves key/value workloads"; 117 license = licenses.bsd3; 118 platforms = platforms.all; 119 maintainers = with maintainers; [ ]; 120 changelog = "https://github.com/valkey-io/valkey/releases/tag/${finalAttrs.version}"; 121 mainProgram = "valkey-cli"; 122 }; 123})