{ 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; [ ]; }; }