2019-11-10 01:46:26 +01:00
|
|
|
{ stdenv, lib
|
|
|
|
, kernel
|
|
|
|
, fetchurl
|
2022-01-26 15:29:01 +01:00
|
|
|
, pkg-config, meson, ninja, makeWrapper
|
2021-12-09 01:59:10 +01:00
|
|
|
, libbsd, numactl, libbpf, zlib, libelf, jansson, openssl, libpcap, rdma-core
|
2022-01-26 15:29:01 +01:00
|
|
|
, doxygen, python3, pciutils
|
2021-07-23 08:25:30 +02:00
|
|
|
, withExamples ? []
|
2023-01-22 00:35:37 +01:00
|
|
|
, shared ? false
|
|
|
|
, machine ? (
|
|
|
|
if stdenv.isx86_64 then "nehalem"
|
|
|
|
else if stdenv.isAarch64 then "generic"
|
|
|
|
else null
|
|
|
|
)
|
|
|
|
}:
|
2016-04-20 17:11:34 +02:00
|
|
|
|
2018-05-21 00:43:35 +02:00
|
|
|
let
|
|
|
|
mod = kernel != null;
|
2023-01-22 00:20:21 +01:00
|
|
|
dpdkVersion = "22.11.1";
|
2018-05-21 00:43:35 +02:00
|
|
|
in stdenv.mkDerivation rec {
|
2021-05-11 16:02:37 +02:00
|
|
|
pname = "dpdk";
|
|
|
|
version = "${dpdkVersion}" + lib.optionalString mod "-${kernel.version}";
|
2016-04-20 17:11:34 +02:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-05-11 16:02:37 +02:00
|
|
|
url = "https://fast.dpdk.org/rel/dpdk-${dpdkVersion}.tar.xz";
|
2023-01-22 00:20:21 +01:00
|
|
|
sha256 = "sha256-3gdkZfcXSg1ScUuQcuSDenJrqsgtj+fcZEytXIz3TUw=";
|
2016-04-20 17:11:34 +02:00
|
|
|
};
|
|
|
|
|
2019-11-10 01:46:26 +01:00
|
|
|
nativeBuildInputs = [
|
2022-01-26 15:29:01 +01:00
|
|
|
makeWrapper
|
2019-11-10 01:46:26 +01:00
|
|
|
doxygen
|
|
|
|
meson
|
|
|
|
ninja
|
2021-01-19 07:50:56 +01:00
|
|
|
pkg-config
|
2019-11-10 01:46:26 +01:00
|
|
|
python3
|
|
|
|
python3.pkgs.sphinx
|
2021-05-11 16:02:37 +02:00
|
|
|
python3.pkgs.pyelftools
|
2019-11-10 01:46:26 +01:00
|
|
|
];
|
|
|
|
buildInputs = [
|
|
|
|
jansson
|
|
|
|
libbpf
|
|
|
|
libelf
|
|
|
|
libpcap
|
|
|
|
numactl
|
|
|
|
openssl.dev
|
|
|
|
zlib
|
2022-01-17 13:50:14 +01:00
|
|
|
python3
|
2019-11-10 01:46:26 +01:00
|
|
|
] ++ lib.optionals mod kernel.moduleBuildDependencies;
|
2016-05-31 14:35:54 +02:00
|
|
|
|
2021-12-09 09:28:18 +01:00
|
|
|
propagatedBuildInputs = [
|
2022-01-25 15:28:25 +01:00
|
|
|
# Propagated to support current DPDK users in nixpkgs which statically link
|
|
|
|
# with the framework (e.g. odp-dpdk).
|
2021-12-09 09:28:18 +01:00
|
|
|
rdma-core
|
2022-01-25 15:28:25 +01:00
|
|
|
# Requested by pkg-config.
|
|
|
|
libbsd
|
2021-12-09 09:28:18 +01:00
|
|
|
];
|
|
|
|
|
2018-05-21 04:32:18 +02:00
|
|
|
postPatch = ''
|
2020-06-30 12:40:58 +02:00
|
|
|
patchShebangs config/arm buildtools
|
2022-01-25 16:17:18 +01:00
|
|
|
'' + 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
|
2018-05-21 00:43:35 +02:00
|
|
|
'';
|
|
|
|
|
2019-11-10 01:46:26 +01:00
|
|
|
mesonFlags = [
|
2021-05-11 16:02:37 +02:00
|
|
|
"-Dtests=false"
|
2019-11-10 01:46:26 +01:00
|
|
|
"-Denable_docs=true"
|
2020-10-14 01:46:17 +02:00
|
|
|
"-Denable_kmods=${lib.boolToString mod}"
|
2019-11-10 01:46:26 +01:00
|
|
|
]
|
2021-05-11 16:02:37 +02:00
|
|
|
# kni kernel driver is currently not compatble with 5.11
|
|
|
|
++ lib.optional (mod && kernel.kernelOlder "5.11") "-Ddisable_drivers=kni"
|
2023-10-05 21:33:18 +02:00
|
|
|
++ [(if shared then "-Ddefault_library=shared" else "-Ddefault_library=static")]
|
2023-01-22 00:35:37 +01:00
|
|
|
++ lib.optional (machine != null) "-Dmachine=${machine}"
|
2022-01-25 16:17:18 +01:00
|
|
|
++ lib.optional mod "-Dkernel_dir=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
2021-07-23 08:25:30 +02:00
|
|
|
++ lib.optional (withExamples != []) "-Dexamples=${builtins.concatStringsSep "," withExamples}";
|
2019-12-23 09:49:35 +01:00
|
|
|
|
2021-12-09 02:17:41 +01:00
|
|
|
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
|
2022-01-26 15:29:01 +01:00
|
|
|
|
|
|
|
wrapProgram $out/bin/dpdk-devbind.py \
|
|
|
|
--prefix PATH : "${lib.makeBinPath [ pciutils ]}"
|
2021-12-09 02:17:41 +01:00
|
|
|
'' + lib.optionalString (withExamples != []) ''
|
2022-01-26 15:29:01 +01:00
|
|
|
mkdir -p $examples/bin
|
|
|
|
find examples -type f -executable -exec install {} $examples/bin \;
|
2021-07-23 08:25:30 +02:00
|
|
|
'';
|
|
|
|
|
2022-01-26 15:29:01 +01:00
|
|
|
outputs =
|
|
|
|
[ "out" "doc" ]
|
|
|
|
++ lib.optional mod "kmod"
|
|
|
|
++ lib.optional (withExamples != []) "examples";
|
2018-05-21 00:43:35 +02:00
|
|
|
|
|
|
|
meta = with lib; {
|
2016-04-20 17:11:34 +02:00
|
|
|
description = "Set of libraries and drivers for fast packet processing";
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://dpdk.org/";
|
2016-04-20 17:11:34 +02:00
|
|
|
license = with licenses; [ lgpl21 gpl2 bsd2 ];
|
2019-11-10 01:46:26 +01:00
|
|
|
platforms = platforms.linux;
|
2021-07-23 08:25:30 +02:00
|
|
|
maintainers = with maintainers; [ magenbluten orivej mic92 zhaofengli ];
|
2022-10-31 13:40:58 +01:00
|
|
|
broken = mod && kernel.isHardened;
|
2016-04-20 17:11:34 +02:00
|
|
|
};
|
|
|
|
}
|