Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv
2, fetchpatch
3, fetchFromGitHub
4, ncurses
5, python3
6, cunit
7, dpdk
8, libaio
9, libbsd
10, libuuid
11, numactl
12, openssl
13, fetchurl
14}:
15
16let
17 # The old version has some CVEs howver they should not affect SPDK's usage of the framework: https://github.com/NixOS/nixpkgs/pull/171648#issuecomment-1121964568
18 dpdk' = dpdk.overrideAttrs (old: rec {
19 name = "dpdk-21.11";
20 src = fetchurl {
21 url = "https://fast.dpdk.org/rel/${name}.tar.xz";
22 sha256 = "sha256-Mkbj7WjuKzaaXYviwGzxCKZp4Vf01Bxby7sha/Wr06E=";
23 };
24 });
25in stdenv.mkDerivation rec {
26 pname = "spdk";
27 version = "21.10";
28
29 src = fetchFromGitHub {
30 owner = "spdk";
31 repo = "spdk";
32 rev = "v${version}";
33 sha256 = "sha256-pFynTbbSF1g58VD9bOhe3c4oCozeqE+35kECTQwDBDM=";
34 };
35
36 patches = [
37 # Backport of upstream patch for ncurses-6.3 support.
38 # Will be in next release after 21.10.
39 ./ncurses-6.3.patch
40
41 # DPDK 21.11 compatibility.
42 (fetchpatch {
43 url = "https://github.com/spdk/spdk/commit/f72cab94dd35d7b45ec5a4f35967adf3184ca616.patch";
44 sha256 = "sha256-sSetvyNjlM/hSOUsUO3/dmPzAliVcteNDvy34yM5d4A=";
45 })
46 ];
47
48 nativeBuildInputs = [
49 python3
50 ];
51
52 buildInputs = [
53 cunit dpdk' libaio libbsd libuuid numactl openssl ncurses
54 ];
55
56 postPatch = ''
57 patchShebangs .
58
59 # glibc-2.36 adds arc4random, so we don't need the custom implementation
60 # here anymore. Fixed upstream in https://github.com/spdk/spdk/commit/43a3984c6c8fde7201d6c8dfe1b680cb88237269,
61 # but the patch doesn't apply here.
62 sed -i -e '1i #define HAVE_ARC4RANDOM 1' lib/iscsi/iscsi.c
63 '';
64
65 enableParallelBuilding = true;
66
67 configureFlags = [ "--with-dpdk=${dpdk'}" ];
68
69 env.NIX_CFLAGS_COMPILE = "-mssse3"; # Necessary to compile.
70 # otherwise does not find strncpy when compiling
71 NIX_LDFLAGS = "-lbsd";
72
73 meta = with lib; {
74 description = "Set of libraries for fast user-mode storage";
75 homepage = "https://spdk.io/";
76 license = licenses.bsd3;
77 platforms = [ "x86_64-linux" ];
78 maintainers = with maintainers; [ orivej ];
79 };
80}