1{ stdenv
2, lib
3, fetchFromGitHub
4, fetchpatch
5, meson
6, ninja
7, pkg-config
8, dpdk
9, libbsd
10, libpcap
11, lua5_3
12, numactl
13, util-linux
14, gtk2
15, which
16, withGtk ? false
17}:
18
19stdenv.mkDerivation rec {
20 pname = "pktgen";
21 version = "22.07.1";
22
23 src = fetchFromGitHub {
24 owner = "pktgen";
25 repo = "Pktgen-DPDK";
26 rev = "pktgen-${version}";
27 sha256 = "sha256-wBLGwVdn3ymUTVv7J/kbQYz4WNIgV246PHg51+FStUo=";
28 };
29
30 patches = [
31 (fetchpatch {
32 # Ealier DPDK deprecated some macros, which were finally removed in >= 22.11
33 url = "https://github.com/pktgen/Pktgen-DPDK/commit/089ef94ac04629f7380f5e618443bcacb2cef5ab.patch";
34 sha256 = "sha256-ITU/dIfu7QPpdIVYuCuDhDG9rVF+n8i1YYn9bFmQUME=";
35 })
36 ];
37
38 nativeBuildInputs = [ meson ninja pkg-config ];
39
40 buildInputs = [
41 dpdk libbsd libpcap lua5_3 numactl which
42 ] ++ lib.optionals withGtk [
43 gtk2
44 ];
45
46 RTE_SDK = dpdk;
47 GUI = lib.optionalString withGtk "true";
48
49 env.NIX_CFLAGS_COMPILE = toString [
50 # Needed with GCC 12
51 "-Wno-error=address"
52 "-Wno-error=use-after-free"
53 ];
54
55 # requires symbols from this file
56 NIX_LDFLAGS = "-lrte_net_bond";
57
58 postPatch = ''
59 substituteInPlace lib/common/lscpu.h --replace /usr/bin/lscpu ${util-linux}/bin/lscpu
60 '';
61
62 postInstall = ''
63 # meson installs unneeded files with conflicting generic names, such as
64 # include/cli.h and lib/liblua.so.
65 rm -rf $out/include $out/lib
66 '';
67
68 meta = with lib; {
69 description = "Traffic generator powered by DPDK";
70 homepage = "http://dpdk.org/";
71 license = licenses.bsdOriginal;
72 platforms = platforms.linux;
73 maintainers = [ maintainers.abuibrahim ];
74 };
75}