liminix/pkgs/iproute2-small/default.nix
sinavir c967cd0b3b
All checks were successful
build liminix / test_shell_customization (pull_request) Successful in 16s
build liminix / test_hostapd (pull_request) Successful in 16s
build liminix / build_vm_qemu_mips (pull_request) Successful in 20s
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 21s
feat: init small iproute2
2025-02-28 17:17:29 +01:00

103 lines
2.6 KiB
Nix

{ lib, stdenv, fetchurl
, buildPackages, bison, flex, pkg-config
, libelf, libnl-tiny
, gitUpdater, breakpointHook, libmnl, db
}:
stdenv.mkDerivation rec {
pname = "iproute2";
version = "6.7.0";
src = fetchurl {
url = "mirror://kernel/linux/utils/net/${pname}/${pname}-${version}.tar.xz";
hash = "sha256-/5Qt2YKNfR+Gf2H+cs5DMHjDHl2OSnjiDwLLWJLohB0=";
};
patches = [
./patches/120-no_arpd_ifstat_rtacct_lnstat.patch
./patches/130-no_netem_tipc_dcb_man_vdpa.patch
./patches/140-allow_pfifo_fast.patch
./patches/160-libnetlink-pic.patch
./patches/170-ip_tiny.patch
./patches/175-reduce-dynamic-syms.patch
./patches/180-drop_FAILED_POLICY.patch
./patches/190-fix-nls-rpath-link.patch
./patches/195-build_variant_ip_tc.patch
];
postPatch = ''
# Don't try to create /var/lib/arpd:
sed -e '/ARPDDIR/d' -i Makefile
substituteInPlace Makefile \
--replace "CC := gcc" "CC ?= $CC"
'';
hardeningDisable = [ "pie" ];
makeFlags = [
"PREFIX=$(out)"
"SBINDIR=$(out)/sbin"
"DOCDIR=$(TMPDIR)/share/doc/${pname}" # Don't install docs
"HDRDIR=$(dev)/include/iproute2"
"V=1"
"BUILD_VARIANT=ip"
"AR=${stdenv.cc.cc}/bin/${stdenv.cc.targetPrefix}gcc-ar"
] ++ lib.optionals stdenv.hostPlatform.isStatic [
"SHARED_LIBS=n"
# all build .so plugins:
"TC_CONFIG_NO_XT=y"
] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"HOSTCC=$(CC_FOR_BUILD)"
];
preBuild = ''
export CFLAGS="-Os -funit-at-a-time -ffunction-sections -fdata-sections -flto=auto -fno-fat-lto-objects"
export LDFLAGS="-Wl,--gc-sections -flto=auto -fuse-linker-plugin"
'';
buildFlags = [
"CONFDIR=/etc/iproute2"
];
installFlags = [
"CONFDIR=$(out)/etc/iproute2"
];
postInstall = ''
rm -r $out/share
rm -r $out/lib
'';
depsBuildBuild = [ buildPackages.stdenv.cc ]; # netem requires $HOSTCC
nativeBuildInputs = [ bison flex pkg-config ];
buildInputs = [
# db
# libelf
# libnl-tiny
# libmnl
];
enableParallelBuilding = true;
stripAllList = [
"bin"
];
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 = "A collection of utilities for controlling TCP/IP networking and traffic control in Linux";
platforms = platforms.linux;
license = licenses.gpl2;
maintainers = with maintainers; [ ];
};
}