about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/dpdk/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/linux/dpdk/default.nix')
-rw-r--r--pkgs/os-specific/linux/dpdk/default.nix41
1 files changed, 21 insertions, 20 deletions
diff --git a/pkgs/os-specific/linux/dpdk/default.nix b/pkgs/os-specific/linux/dpdk/default.nix
index 7592be483f532..1e4f50e42df38 100644
--- a/pkgs/os-specific/linux/dpdk/default.nix
+++ b/pkgs/os-specific/linux/dpdk/default.nix
@@ -1,9 +1,9 @@
 { stdenv, lib
 , kernel
 , fetchurl
-, pkg-config, meson, ninja
+, pkg-config, meson, ninja, makeWrapper
 , libbsd, numactl, libbpf, zlib, libelf, jansson, openssl, libpcap, rdma-core
-, doxygen, python3
+, doxygen, python3, pciutils
 , withExamples ? []
 , shared ? false }:
 
@@ -20,6 +20,7 @@ in stdenv.mkDerivation rec {
   };
 
   nativeBuildInputs = [
+    makeWrapper
     doxygen
     meson
     ninja
@@ -31,22 +32,27 @@ in stdenv.mkDerivation rec {
   buildInputs = [
     jansson
     libbpf
-    libbsd
     libelf
     libpcap
     numactl
     openssl.dev
     zlib
+    python3
   ] ++ lib.optionals mod kernel.moduleBuildDependencies;
 
-  # Propagated to support current DPDK users in nixpkgs which statically link
-  # with the framework (e.g. odp-dpdk).
   propagatedBuildInputs = [
+    # Propagated to support current DPDK users in nixpkgs which statically link
+    # with the framework (e.g. odp-dpdk).
     rdma-core
+    # Requested by pkg-config.
+    libbsd
   ];
 
   postPatch = ''
     patchShebangs config/arm buildtools
+  '' + lib.optionalString mod ''
+    # kernel_install_dir is hardcoded to `/lib/modules`; patch that.
+    sed -i "s,kernel_install_dir *= *['\"].*,kernel_install_dir = '$kmod/lib/modules/${kernel.modDirVersion}'," kernel/linux/meson.build
   '';
 
   mesonFlags = [
@@ -59,30 +65,25 @@ in stdenv.mkDerivation rec {
   ++ lib.optional (!shared) "-Ddefault_library=static"
   ++ lib.optional stdenv.isx86_64 "-Dmachine=nehalem"
   ++ lib.optional stdenv.isAarch64 "-Dmachine=generic"
-  ++ lib.optional mod "-Dkernel_dir=${placeholder "kmod"}/lib/modules/${kernel.modDirVersion}"
+  ++ lib.optional mod "-Dkernel_dir=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
   ++ lib.optional (withExamples != []) "-Dexamples=${builtins.concatStringsSep "," withExamples}";
 
-  # dpdk meson script does not support separate kernel source and installion
-  # dirs (except via destdir), so we temporarily link the former into the latter.
-  preConfigure = lib.optionalString mod ''
-    mkdir -p $kmod/lib/modules/${kernel.modDirVersion}
-    ln -sf ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
-      $kmod/lib/modules/${kernel.modDirVersion}
-  '';
-
-  postBuild = lib.optionalString mod ''
-    rm -f $kmod/lib/modules/${kernel.modDirVersion}/build
-  '';
-
   postInstall = ''
     # Remove Sphinx cache files. Not only are they not useful, but they also
     # contain store paths causing spurious dependencies.
     rm -rf $out/share/doc/dpdk/html/.doctrees
+
+    wrapProgram $out/bin/dpdk-devbind.py \
+      --prefix PATH : "${lib.makeBinPath [ pciutils ]}"
   '' + lib.optionalString (withExamples != []) ''
-    find examples -type f -executable -exec install {} $out/bin \;
+    mkdir -p $examples/bin
+    find examples -type f -executable -exec install {} $examples/bin \;
   '';
 
-  outputs = [ "out" ] ++ lib.optional mod "kmod";
+  outputs =
+    [ "out" "doc" ]
+    ++ lib.optional mod "kmod"
+    ++ lib.optional (withExamples != []) "examples";
 
   meta = with lib; {
     description = "Set of libraries and drivers for fast packet processing";