152 lines
3.9 KiB
Nix
152 lines
3.9 KiB
Nix
|
{
|
||
|
lib,
|
||
|
stdenv,
|
||
|
fetchurl,
|
||
|
fetchpatch,
|
||
|
buildPackages,
|
||
|
bison,
|
||
|
flex,
|
||
|
pkg-config,
|
||
|
elfutils,
|
||
|
libmnl,
|
||
|
libbpf,
|
||
|
gitUpdater,
|
||
|
pkgsStatic,
|
||
|
breakpointHook,
|
||
|
|
||
|
}:
|
||
|
|
||
|
stdenv.mkDerivation rec {
|
||
|
pname = "iproute2";
|
||
|
version = "6.11.0";
|
||
|
|
||
|
src = fetchurl {
|
||
|
url = "mirror://kernel/linux/utils/net/${pname}/${pname}-${version}.tar.xz";
|
||
|
hash = "sha256-H3lTmKBK6qzQao9qziz9kTwz+llTypnaroO7XFNGEcM=";
|
||
|
};
|
||
|
|
||
|
patches = [
|
||
|
./patches/010-bridge-mst-fix-a-musl-build-issue.patch
|
||
|
./patches/011-bridge-mst-fix-a-further-musl-build-issue.patch
|
||
|
./patches/012-libnetlink-fix-build-with-musl-and-gcc-14.patch
|
||
|
./patches/110-darwin_fixes.patch
|
||
|
./patches/115-add-config-xtlibdir.patch
|
||
|
./patches/120-no_arpd_ifstat_rtacct_lnstat.patch
|
||
|
./patches/130-no_netem_tipc_dcb_man_vdpa.patch
|
||
|
./patches/140-allow_pfifo_fast.patch
|
||
|
./patches/140-keep_libmnl_optional.patch
|
||
|
./patches/145-keep_libelf_optional.patch
|
||
|
./patches/150-keep_libcap_optional.patch
|
||
|
./patches/155-keep_tirpc_optional.patch
|
||
|
./patches/160-libnetlink-pic.patch
|
||
|
./patches/170-ip_tiny.patch
|
||
|
./patches/180-drop_FAILED_POLICY.patch
|
||
|
./patches/190-fix-nls-rpath-link.patch
|
||
|
./patches/195-build_variant_ip_tc.patch
|
||
|
./patches/200-drop_libbsd_dependency.patch
|
||
|
./patches/300-selinux-configurable.patch
|
||
|
./patches/400-rdma-include-libgen.h-for-basename.patch
|
||
|
(fetchurl {
|
||
|
name = "musl-endian.patch";
|
||
|
url = "https://lore.kernel.org/netdev/20240712191209.31324-1-contact@hacktivis.me/raw";
|
||
|
hash = "sha256-MX+P+PSEh6XlhoWgzZEBlOV9aXhJNd20Gi0fJCcSZ5E=";
|
||
|
})
|
||
|
(fetchurl {
|
||
|
name = "musl-msghdr.patch";
|
||
|
url = "https://lore.kernel.org/netdev/20240712191209.31324-2-contact@hacktivis.me/raw";
|
||
|
hash = "sha256-X5BYSZBxcvdjtX1069a1GfcpdoVd0loSAe4xTpbCipA=";
|
||
|
})
|
||
|
(fetchurl {
|
||
|
name = "musl-basename.patch";
|
||
|
url = "https://lore.kernel.org/netdev/20240804161054.942439-1-dilfridge@gentoo.org/raw";
|
||
|
hash = "sha256-47obv6mIn/HO47lt47slpTAFDxiQ3U/voHKzIiIGCTM=";
|
||
|
})
|
||
|
# Duplicate
|
||
|
# (fetchpatch {
|
||
|
# name = "musl-mst.patch";
|
||
|
# url = "https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/patch/?id=6a77abab92516e65f07f8657fc4e384c4541ce0e";
|
||
|
# hash = "sha256-19FzTDvgnmqVFBykVgXl4VIsHs8Cy9NWGOLpxifxVlI=";
|
||
|
# })
|
||
|
];
|
||
|
|
||
|
postPatch = ''
|
||
|
substituteInPlace Makefile \
|
||
|
--replace "CC := gcc" "CC ?= $CC"
|
||
|
'';
|
||
|
|
||
|
outputs = [
|
||
|
"out"
|
||
|
"dev"
|
||
|
];
|
||
|
|
||
|
configureFlags = [
|
||
|
"--color"
|
||
|
"auto"
|
||
|
];
|
||
|
|
||
|
makeFlags =
|
||
|
[
|
||
|
"PREFIX=$(out)"
|
||
|
"SBINDIR=$(out)/sbin"
|
||
|
"DOCDIR=$(TMPDIR)/share/doc/${pname}" # Don't install docs
|
||
|
"HDRDIR=$(dev)/include/iproute2"
|
||
|
|
||
|
### openwrt
|
||
|
|
||
|
"BUILD_VARIANT=ip-full"
|
||
|
"LIBBPF_FORCE=on"
|
||
|
"HAVE_LIBBPF=y"
|
||
|
"HAVE_ELF=y"
|
||
|
"HAVE_MNL=y"
|
||
|
"HAVE_CAP=n"
|
||
|
"HAVE_TIRPC=n"
|
||
|
]
|
||
|
++ lib.optionals stdenv.hostPlatform.isStatic [
|
||
|
"SHARED_LIBS=n"
|
||
|
]
|
||
|
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
|
||
|
"HOSTCC=$(CC_FOR_BUILD)"
|
||
|
];
|
||
|
|
||
|
buildFlags = [
|
||
|
"CONFDIR=/etc/iproute2"
|
||
|
];
|
||
|
|
||
|
installFlags = [
|
||
|
"CONFDIR=$(out)/etc/iproute2"
|
||
|
];
|
||
|
|
||
|
depsBuildBuild = [ buildPackages.stdenv.cc ]; # netem requires $HOSTCC
|
||
|
nativeBuildInputs = [
|
||
|
breakpointHook
|
||
|
bison
|
||
|
flex
|
||
|
pkg-config
|
||
|
];
|
||
|
buildInputs =
|
||
|
[
|
||
|
libmnl
|
||
|
libbpf
|
||
|
]
|
||
|
# needed to uploaded bpf programs
|
||
|
++ lib.optionals (!stdenv.hostPlatform.isStatic) [
|
||
|
elfutils
|
||
|
libbpf
|
||
|
];
|
||
|
|
||
|
enableParallelBuilding = true;
|
||
|
|
||
|
passthru.updateScript = gitUpdater {
|
||
|
# No nicer place to find latest release.
|
||
|
url = "https://git.kernel.org/pub/scm/network/iproute2/iproute2.git";
|
||
|
rev-prefix = "v";
|
||
|
};
|
||
|
|
||
|
meta = with lib; {
|
||
|
homepage = "https://wiki.linuxfoundation.org/networking/iproute2";
|
||
|
description = "Collection of utilities for controlling TCP/IP networking and traffic control in Linux";
|
||
|
platforms = platforms.linux;
|
||
|
license = licenses.gpl2Only;
|
||
|
};
|
||
|
}
|