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