summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/vp/vpp/package.nix
blob: 4ce186d8d3ed39ccc144162c5d9b5b43f773671a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{
  lib,
  stdenv,
  fetchFromGitHub,
  nix-update-script,
  writeText,

  cmake,
  pkg-config,
  python3,

  # optional dependencies
  withStackTraces ? true,
  libiberty,
  libunwind,

  withOpenssl ? true, # tls/quic/wireguard plugins
  openssl,

  withLibPcap ? true, # bpf_trace_filter plugin
  libpcap,

  withNetlinkLibs ? true, # linux-cp plugin
  libnl,
  libmnl,

  withRdma ? true,
  rdma-core,

  withDpdk ? true,
  dpdk,
  jansson,

  withAfXdp ? true,
  xdp-tools,
  libbpf,
  # Support for all network cards, but slower than native XDP
  enableAfXdpSkbMode ? false,

  libelf,
  zlib,
}:
let
  dpdk' = dpdk.overrideAttrs (old: {
    mesonFlags = old.mesonFlags ++ [ "-Denable_driver_sdk=true" ];
  });

  # >=25.02 uses /etc/os-release, so we substitute it
  osRelease = writeText "os-release" "ID=nixos";
in
stdenv.mkDerivation (finalAttrs: {
  pname = "vpp";
  version = "26.02";

  src = fetchFromGitHub {
    owner = "FDio";
    repo = "vpp";
    tag = "v${finalAttrs.version}";
    hash = "sha256-z9yh1ZMP28SSzHNBdO7UnvVqsIqtXUcwYZUH1UdBUB0=";
  };

  postPatch = ''
    patchShebangs scripts/
    substituteInPlace pkg/CMakeLists.txt \
      --replace-fail "/etc/os-release" "${osRelease}"
  '';

  preConfigure = ''
    echo "${finalAttrs.version}-nixos" > scripts/.version
    ./scripts/version
  '';

  postConfigure = ''
    patchShebangs ../tools/
    patchShebangs ../vpp-api/
  '';

  sourceRoot = "${finalAttrs.src.name}/src";

  enableParallelBuilding = true;
  cmakeFlags = [
    "-DVPP_PLATFORM=default"
    "-DVPP_LIBRARY_DIR=lib"
    "-DVPP_BUILD_PYTHON_API=false" # fails to build as of 25.10
  ]
  ++ lib.optional withDpdk "-DVPP_USE_SYSTEM_DPDK=ON";

  nativeBuildInputs = [
    cmake
    pkg-config
    (python3.withPackages (ps: [ ps.ply ]))
  ];

  buildInputs =
    lib.optionals withStackTraces [
      libiberty
      libunwind
    ]
    ++ lib.optional withOpenssl openssl
    ++ lib.optional withLibPcap libpcap
    ++ lib.optionals withNetlinkLibs [
      libnl
      libmnl
    ]
    ++ lib.optionals withDpdk [
      dpdk'
      jansson
      libelf
      zlib
    ]
    ++ lib.optional withRdma rdma-core
    ++ lib.optionals withAfXdp [
      libelf
      libbpf
      xdp-tools
      zlib
    ];

  strictDeps = true;

  patches = [
    # VPP links to static RDMA/XDP by default
    ./use-dynamic-libs.patch
  ]
  ++ lib.optional enableAfXdpSkbMode ./xdp-skb-mode.patch;

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Fast, scalable layer 2-4 multi-platform network stack running in user space";
    homepage = "https://s3-docs.fd.io/vpp/${finalAttrs.version}/";
    license = lib.licenses.asl20;
    platforms = lib.platforms.linux;
    mainProgram = "vpp";
    maintainers = with lib.maintainers; [ maevii ];
  };
})