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