1{ stdenv, lib
2, kernel
3, fetchurl
4, pkg-config, meson, ninja, makeWrapper
5, libbsd, numactl, libbpf, zlib, libelf, jansson, openssl, libpcap, rdma-core
6, doxygen, python3, pciutils
7, withExamples ? []
8, shared ? false }:
9
10let
11 mod = kernel != null;
12 dpdkVersion = "22.07";
13in stdenv.mkDerivation rec {
14 pname = "dpdk";
15 version = "${dpdkVersion}" + lib.optionalString mod "-${kernel.version}";
16
17 src = fetchurl {
18 url = "https://fast.dpdk.org/rel/dpdk-${dpdkVersion}.tar.xz";
19 sha256 = "sha256-n2Tf3gdf21cIy2Leg4uP+4kVdf7R4dKusma6yj38m+o=";
20 };
21
22 nativeBuildInputs = [
23 makeWrapper
24 doxygen
25 meson
26 ninja
27 pkg-config
28 python3
29 python3.pkgs.sphinx
30 python3.pkgs.pyelftools
31 ];
32 buildInputs = [
33 jansson
34 libbpf
35 libelf
36 libpcap
37 numactl
38 openssl.dev
39 zlib
40 python3
41 ] ++ lib.optionals mod kernel.moduleBuildDependencies;
42
43 propagatedBuildInputs = [
44 # Propagated to support current DPDK users in nixpkgs which statically link
45 # with the framework (e.g. odp-dpdk).
46 rdma-core
47 # Requested by pkg-config.
48 libbsd
49 ];
50
51 postPatch = ''
52 patchShebangs config/arm buildtools
53 '' + lib.optionalString mod ''
54 # kernel_install_dir is hardcoded to `/lib/modules`; patch that.
55 sed -i "s,kernel_install_dir *= *['\"].*,kernel_install_dir = '$kmod/lib/modules/${kernel.modDirVersion}'," kernel/linux/meson.build
56 '';
57
58 mesonFlags = [
59 "-Dtests=false"
60 "-Denable_docs=true"
61 "-Denable_kmods=${lib.boolToString mod}"
62 ]
63 # kni kernel driver is currently not compatble with 5.11
64 ++ lib.optional (mod && kernel.kernelOlder "5.11") "-Ddisable_drivers=kni"
65 ++ lib.optional (!shared) "-Ddefault_library=static"
66 ++ lib.optional stdenv.isx86_64 "-Dmachine=nehalem"
67 ++ lib.optional stdenv.isAarch64 "-Dmachine=generic"
68 ++ lib.optional mod "-Dkernel_dir=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
69 ++ lib.optional (withExamples != []) "-Dexamples=${builtins.concatStringsSep "," withExamples}";
70
71 postInstall = ''
72 # Remove Sphinx cache files. Not only are they not useful, but they also
73 # contain store paths causing spurious dependencies.
74 rm -rf $out/share/doc/dpdk/html/.doctrees
75
76 wrapProgram $out/bin/dpdk-devbind.py \
77 --prefix PATH : "${lib.makeBinPath [ pciutils ]}"
78 '' + lib.optionalString (withExamples != []) ''
79 mkdir -p $examples/bin
80 find examples -type f -executable -exec install {} $examples/bin \;
81 '';
82
83 outputs =
84 [ "out" "doc" ]
85 ++ lib.optional mod "kmod"
86 ++ lib.optional (withExamples != []) "examples";
87
88 meta = with lib; {
89 description = "Set of libraries and drivers for fast packet processing";
90 homepage = "http://dpdk.org/";
91 license = with licenses; [ lgpl21 gpl2 bsd2 ];
92 platforms = platforms.linux;
93 maintainers = with maintainers; [ magenbluten orivej mic92 zhaofengli ];
94 broken = mod && kernel.isHardened;
95 };
96}