|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchFromGitHub, |
| 5 | + nix-update-script, |
| 6 | + cmake, |
| 7 | + pkg-config, |
| 8 | + check, |
| 9 | + openssl, |
| 10 | + python3, |
| 11 | + subunit, |
| 12 | + mbedtls_2, |
| 13 | + libpcap, |
| 14 | + libnl, |
| 15 | + libmnl, |
| 16 | + libelf, |
| 17 | + dpdk, |
| 18 | + jansson, |
| 19 | + zlib, |
| 20 | + rdma-core, |
| 21 | + libbpf, |
| 22 | + xdp-tools, |
| 23 | + enableDpdk ? true, |
| 24 | + enableRdma ? true, |
| 25 | + # FIXME: broken: af_xdp plugins - no working libbpf found - af_xdp plugin disabled |
| 26 | + enableAfXdp ? false, |
| 27 | +}: |
| 28 | + |
| 29 | +let |
| 30 | + dpdk' = dpdk.overrideAttrs (old: { |
| 31 | + mesonFlags = old.mesonFlags ++ [ "-Denable_driver_sdk=true" ]; |
| 32 | + }); |
| 33 | + |
| 34 | + rdma-core' = rdma-core.overrideAttrs (old: { |
| 35 | + cmakeFlags = old.cmakeFlags ++ [ |
| 36 | + "-DENABLE_STATIC=1" |
| 37 | + "-DBUILD_SHARED_LIBS:BOOL=false" |
| 38 | + ]; |
| 39 | + }); |
| 40 | + |
| 41 | + xdp-tools' = xdp-tools.overrideAttrs (old: { |
| 42 | + postInstall = ""; |
| 43 | + dontDisableStatic = true; |
| 44 | + }); |
| 45 | +in |
| 46 | +stdenv.mkDerivation rec { |
| 47 | + pname = "vpp"; |
| 48 | + version = "24.06"; |
| 49 | + |
| 50 | + src = fetchFromGitHub { |
| 51 | + owner = "FDio"; |
| 52 | + repo = "vpp"; |
| 53 | + rev = "v${version}"; |
| 54 | + hash = "sha256-AbdtH3ha/Bzj9tAkp4OhjRcUZilUEt+At0LukWN2LJU="; |
| 55 | + }; |
| 56 | + |
| 57 | + postPatch = '' |
| 58 | + patchShebangs scripts/ |
| 59 | + substituteInPlace CMakeLists.txt \ |
| 60 | + --replace "plugins tools/vppapigen tools/g2 tools/perftool cmake pkg" \ |
| 61 | + "plugins tools/vppapigen tools/g2 tools/perftool cmake" |
| 62 | + ''; |
| 63 | + |
| 64 | + preConfigure = '' |
| 65 | + echo "${version}-nixos" > scripts/.version |
| 66 | + scripts/version |
| 67 | + ''; |
| 68 | + |
| 69 | + postConfigure = '' |
| 70 | + patchShebangs ../tools/ |
| 71 | + patchShebangs ../vpp-api/ |
| 72 | + ''; |
| 73 | + |
| 74 | + sourceRoot = "source/src"; |
| 75 | + |
| 76 | + enableParallelBuilding = true; |
| 77 | + env.NIX_CFLAGS_COMPILE = "-Wno-error -Wno-array-bounds -Wno-maybe-uninitialized"; |
| 78 | + |
| 79 | + cmakeFlags = [ |
| 80 | + "-DVPP_PLATFORM=default" |
| 81 | + "-DVPP_LIBRARY_DIR=lib" |
| 82 | + ] ++ lib.optional enableDpdk "-DVPP_USE_SYSTEM_DPDK=ON"; |
| 83 | + |
| 84 | + nativeBuildInputs = [ |
| 85 | + cmake |
| 86 | + pkg-config |
| 87 | + ] ++ lib.optional enableDpdk dpdk' ++ lib.optional enableRdma rdma-core'.dev; |
| 88 | + |
| 89 | + buildInputs = |
| 90 | + [ |
| 91 | + check |
| 92 | + openssl |
| 93 | + (python3.withPackages (ps: [ ps.ply ])) |
| 94 | + |
| 95 | + subunit # vapi tests |
| 96 | + mbedtls_2 # tlsmbed plugin |
| 97 | + libpcap # bpf_trace_filter plugin |
| 98 | + |
| 99 | + # linux-cp plugin |
| 100 | + libnl |
| 101 | + libmnl |
| 102 | + ] |
| 103 | + ++ lib.optionals enableDpdk [ |
| 104 | + # dpdk plugin |
| 105 | + libelf |
| 106 | + jansson |
| 107 | + zlib |
| 108 | + ] |
| 109 | + ++ lib.optionals enableAfXdp [ |
| 110 | + # af_xdp plugin |
| 111 | + libelf |
| 112 | + libbpf |
| 113 | + xdp-tools' |
| 114 | + ]; |
| 115 | + |
| 116 | + passthru.updateScript = nix-update-script { }; |
| 117 | + |
| 118 | + meta = { |
| 119 | + description = "Fast, scalable layer 2-4 multi-platform network stack running in user space"; |
| 120 | + homepage = "https://s3-docs.fd.io/vpp/${version}/"; |
| 121 | + license = [ lib.licenses.asl20 ]; |
| 122 | + maintainers = with lib.maintainers; [ romner-set ]; |
| 123 | + mainProgram = "vpp"; |
| 124 | + platforms = lib.platforms.linux; |
| 125 | + }; |
| 126 | +} |
0 commit comments