summary refs log tree commit diff
path: root/pkgs/os-specific/linux/dpdk/default.nix
blob: 0f55fa963a42b02bbd92ec4e202ea43bf785b756 (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
65
66
67
68
69
70
71
{ stdenv, lib, kernel, fetchurl, pkgconfig, libvirt }:

assert lib.versionAtLeast kernel.version "3.18";

stdenv.mkDerivation rec {
  name = "dpdk-${version}-${kernel.version}";
  version = "16.07";

  src = fetchurl {
    url = "http://dpdk.org/browse/dpdk/snapshot/dpdk-${version}.tar.gz";
    sha256 = "1sgh55w3xpc0lb70s74cbyryxdjijk1fbv9b25jy8ms3lxaj966c";
  };

  buildInputs = [ pkgconfig libvirt ];

  RTE_KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
  RTE_TARGET = "x86_64-native-linuxapp-gcc";

  # we need sse3 instructions to build
  NIX_CFLAGS_COMPILE = [ "-march=core2" ];

  enableParallelBuilding = true;
  outputs = [ "out" "kmod" "examples" ];

  hardeningDisable = [ "pic" ];

  configurePhase = ''
    make T=x86_64-native-linuxapp-gcc config
  '';

  buildPhase = ''
    make T=x86_64-native-linuxapp-gcc install
    make T=x86_64-native-linuxapp-gcc examples
  '';

  installPhase = ''
    install -m 0755 -d $out/lib
    install -m 0644 ${RTE_TARGET}/lib/*.a $out/lib

    install -m 0755 -d $out/include
    install -m 0644 ${RTE_TARGET}/include/*.h $out/include

    install -m 0755 -d $out/include/generic
    install -m 0644 ${RTE_TARGET}/include/generic/*.h $out/include/generic

    install -m 0755 -d $out/include/exec-env
    install -m 0644 ${RTE_TARGET}/include/exec-env/*.h $out/include/exec-env

    install -m 0755 -d $out/${RTE_TARGET}
    install -m 0644 ${RTE_TARGET}/.config $out/${RTE_TARGET}

    install -m 0755 -d $out/${RTE_TARGET}/include
    install -m 0644 ${RTE_TARGET}/include/rte_config.h $out/${RTE_TARGET}/include

    cp -pr mk scripts $out/

    mkdir -p $kmod/lib/modules/${kernel.modDirVersion}/kernel/drivers/net
    cp ${RTE_TARGET}/kmod/*.ko $kmod/lib/modules/${kernel.modDirVersion}/kernel/drivers/net

    mkdir -p $examples/bin
    find examples ${RTE_TARGET}/app -type f -executable -exec cp {} $examples/bin \;
  '';

  meta = with stdenv.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 = [ maintainers.domenkozar ];
  };
}