diff options
Diffstat (limited to 'pkgs/os-specific/linux/dpdk/default.nix')
-rw-r--r-- | pkgs/os-specific/linux/dpdk/default.nix | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/pkgs/os-specific/linux/dpdk/default.nix b/pkgs/os-specific/linux/dpdk/default.nix index ca8905e6240..c92f40e3935 100644 --- a/pkgs/os-specific/linux/dpdk/default.nix +++ b/pkgs/os-specific/linux/dpdk/default.nix @@ -1,25 +1,32 @@ { stdenv, lib , kernel , fetchurl -, pkg-config, meson, ninja -, libbsd, numactl, libbpf, zlib, libelf, jansson, openssl, libpcap -, doxygen, python3 +, pkg-config, meson, ninja, makeWrapper +, libbsd, numactl, libbpf, zlib, libelf, jansson, openssl, libpcap, rdma-core +, doxygen, python3, pciutils , withExamples ? [] -, shared ? false }: +, shared ? false +, machine ? ( + if stdenv.isx86_64 then "nehalem" + else if stdenv.isAarch64 then "generic" + else null + ) +}: let mod = kernel != null; - dpdkVersion = "21.05"; -in stdenv.mkDerivation rec { + dpdkVersion = "23.07"; +in stdenv.mkDerivation { pname = "dpdk"; version = "${dpdkVersion}" + lib.optionalString mod "-${kernel.version}"; src = fetchurl { url = "https://fast.dpdk.org/rel/dpdk-${dpdkVersion}.tar.xz"; - sha256 = "sha256-HhJJm0xfzbV8g+X+GE6mvs3ffPCSiTwsXvLvsO7BLws="; + sha256 = "sha256-4IYU6K65KUB9c9cWmZKJpE70A0NSJx8JOX7vkysjs9Y="; }; nativeBuildInputs = [ + makeWrapper doxygen meson ninja @@ -31,16 +38,27 @@ in stdenv.mkDerivation rec { buildInputs = [ jansson libbpf - libbsd libelf libpcap numactl openssl.dev zlib + python3 ] ++ lib.optionals mod kernel.moduleBuildDependencies; + propagatedBuildInputs = [ + # Propagated to support current DPDK users in nixpkgs which statically link + # with the framework (e.g. odp-dpdk). + rdma-core + # Requested by pkg-config. + libbsd + ]; + postPatch = '' patchShebangs config/arm buildtools + '' + lib.optionalString mod '' + # kernel_install_dir is hardcoded to `/lib/modules`; patch that. + sed -i "s,kernel_install_dir *= *['\"].*,kernel_install_dir = '$kmod/lib/modules/${kernel.modDirVersion}'," kernel/linux/meson.build ''; mesonFlags = [ @@ -50,28 +68,27 @@ in stdenv.mkDerivation rec { ] # kni kernel driver is currently not compatble with 5.11 ++ lib.optional (mod && kernel.kernelOlder "5.11") "-Ddisable_drivers=kni" - ++ lib.optional (!shared) "-Ddefault_library=static" - ++ lib.optional stdenv.isx86_64 "-Dmachine=nehalem" - ++ lib.optional mod "-Dkernel_dir=${placeholder "kmod"}/lib/modules/${kernel.modDirVersion}" + ++ [(if shared then "-Ddefault_library=shared" else "-Ddefault_library=static")] + ++ lib.optional (machine != null) "-Dmachine=${machine}" + ++ lib.optional mod "-Dkernel_dir=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" ++ lib.optional (withExamples != []) "-Dexamples=${builtins.concatStringsSep "," withExamples}"; - # dpdk meson script does not support separate kernel source and installion - # dirs (except via destdir), so we temporarily link the former into the latter. - preConfigure = lib.optionalString mod '' - mkdir -p $kmod/lib/modules/${kernel.modDirVersion} - ln -sf ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \ - $kmod/lib/modules/${kernel.modDirVersion} - ''; - - postBuild = lib.optionalString mod '' - rm -f $kmod/lib/modules/${kernel.modDirVersion}/build - ''; + postInstall = '' + # Remove Sphinx cache files. Not only are they not useful, but they also + # contain store paths causing spurious dependencies. + rm -rf $out/share/doc/dpdk/html/.doctrees - postInstall = lib.optionalString (withExamples != []) '' - find examples -type f -executable -exec install {} $out/bin \; + wrapProgram $out/bin/dpdk-devbind.py \ + --prefix PATH : "${lib.makeBinPath [ pciutils ]}" + '' + lib.optionalString (withExamples != []) '' + mkdir -p $examples/bin + find examples -type f -executable -exec install {} $examples/bin \; ''; - outputs = [ "out" ] ++ lib.optional mod "kmod"; + outputs = + [ "out" "doc" ] + ++ lib.optional mod "kmod" + ++ lib.optional (withExamples != []) "examples"; meta = with lib; { description = "Set of libraries and drivers for fast packet processing"; @@ -79,5 +96,6 @@ in stdenv.mkDerivation rec { license = with licenses; [ lgpl21 gpl2 bsd2 ]; platforms = platforms.linux; maintainers = with maintainers; [ magenbluten orivej mic92 zhaofengli ]; + broken = mod && kernel.isHardened; }; } |