summary refs log tree commit diff
path: root/pkgs/os-specific/linux/dpdk/default.nix
blob: 888f446175da26b4ca9c8bc7f6ff0a1dd2dae356 (plain) (blame)
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
{ stdenv, lib, kernel, fetchurl, pkgconfig, numactl, shared ? false }:

let

  kver = kernel.modDirVersion or null;

  mod = kernel != null;

in stdenv.mkDerivation rec {
  name = "dpdk-${version}" + lib.optionalString mod "-${kernel.version}";
  version = "19.05";

  src = fetchurl {
    url = "https://fast.dpdk.org/rel/dpdk-${version}.tar.xz";
    sha256 = "1pvxyjx2fpsf15fi8vz7zfkaywihck2yd4ck525w76fl15irw3f8";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ numactl ] ++ lib.optional mod kernel.moduleBuildDependencies;

  RTE_KERNELDIR = if mod then "${kernel.dev}/lib/modules/${kver}/build" else "/var/empty";
  RTE_TARGET = "x86_64-native-linuxapp-gcc";

  # we need sse3 instructions to build
  NIX_CFLAGS_COMPILE = [ "-msse3" ];
  hardeningDisable = [ "pic" ];

  postPatch = ''
    cat >>config/defconfig_$RTE_TARGET <<EOF
# Build static or shared libraries.
CONFIG_RTE_BUILD_SHARED_LIB=${if shared then "y" else "n"}
EOF
  '' + lib.optionalString (!mod) ''
    cat >>config/defconfig_$RTE_TARGET <<EOF
# Do not build kernel modules.
CONFIG_RTE_EAL_IGB_UIO=n
CONFIG_RTE_KNI_KMOD=n
EOF
  '';

  configurePhase = ''
    make T=${RTE_TARGET} config
  '';

  installTargets = [ "install-runtime" "install-sdk" "install-kmod" ]; # skip install-doc

  installFlags = [
    "prefix=$(out)"
  ] ++ lib.optionals mod [
    "kerneldir=$(kmod)/lib/modules/${kver}"
  ];

  outputs = [ "out" ] ++ lib.optional mod "kmod";

  enableParallelBuilding = true;

  meta = with lib; {
    description = "Set of libraries and drivers for fast packet processing";
    homepage = http://dpdk.org/;
    license = with licenses; [ lgpl21 gpl2 bsd2 ];
    platforms =  [ "x86_64-linux" ];
    maintainers = with maintainers; [ domenkozar magenbluten orivej ];
  };
}