nixpkgs/pkgs/os-specific/linux/dpdk/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

90 lines
2.3 KiB
Nix

{ stdenv, lib
, fetchurl
, pkg-config, meson, ninja, makeWrapper
, libbsd, numactl, libbpf, zlib, elfutils, jansson, openssl, libpcap, rdma-core
, doxygen, python3, pciutils
, withExamples ? []
, shared ? false
, machine ? (
if stdenv.hostPlatform.isx86_64 then "nehalem"
else if stdenv.hostPlatform.isAarch64 then "generic"
else null
)
}:
stdenv.mkDerivation rec {
pname = "dpdk";
version = "23.11";
src = fetchurl {
url = "https://fast.dpdk.org/rel/dpdk-${version}.tar.xz";
sha256 = "sha256-ZPpY/fyelRDo5BTjvt0WW9PUykZaIxsoAyP4PNU/2GU=";
};
nativeBuildInputs = [
makeWrapper
doxygen
meson
ninja
pkg-config
python3
python3.pkgs.sphinx
python3.pkgs.pyelftools
];
buildInputs = [
jansson
libbpf
elfutils
libpcap
numactl
openssl.dev
zlib
python3
];
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
'';
mesonFlags = [
"-Dtests=false"
"-Denable_docs=true"
"-Ddeveloper_mode=disabled"
]
++ [(if shared then "-Ddefault_library=shared" else "-Ddefault_library=static")]
++ lib.optional (machine != null) "-Dmachine=${machine}"
++ lib.optional (withExamples != []) "-Dexamples=${builtins.concatStringsSep "," withExamples}";
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 != []) ''
mkdir -p $examples/bin
find examples -type f -executable -exec install {} $examples/bin \;
'';
outputs =
[ "out" "doc" ]
++ lib.optional (withExamples != []) "examples";
meta = with lib; {
description = "Set of libraries and drivers for fast packet processing";
homepage = "http://dpdk.org/";
license = with licenses; [ lgpl21 gpl2Only bsd2 ];
platforms = platforms.linux;
maintainers = with maintainers; [ magenbluten orivej mic92 zhaofengli ];
};
}