1{ lib, stdenv, fetchurl, fetchpatch
2, buildPackages, bison, flex, pkg-config
3, db, iptables, libelf, libmnl
4, gitUpdater
5}:
6
7stdenv.mkDerivation rec {
8 pname = "iproute2";
9 version = "5.19.0";
10
11 src = fetchurl {
12 url = "mirror://kernel/linux/utils/net/${pname}/${pname}-${version}.tar.xz";
13 sha256 = "JrejTWp/0vekLis5xakMthusUi0QlgZ//rGV5Wk9d5E=";
14 };
15
16 patches = [
17 # To avoid ./configure failing due to invalid arguments:
18 (fetchpatch { # configure: restore backward compatibility
19 url = "https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/patch/?id=a3272b93725a406bc98b67373da67a4bdf6fcdb0";
20 sha256 = "0hyagh2lf6rrfss4z7ca8q3ydya6gg7vfhh25slhpgcn6lnk0xbv";
21 })
22
23 # fix build on musl. applied anywhere to prevent patchrot.
24 (fetchpatch {
25 url = "https://git.alpinelinux.org/aports/plain/main/iproute2/min.patch?id=4b78dbe29d18151402052c56af43cc12d04b1a69";
26 sha256 = "sha256-0ROZQAN3mUPPgggictr23jyA4JDG7m9vmBUhgRp4ExY=";
27 })
28 ];
29
30 preConfigure = ''
31 # Don't try to create /var/lib/arpd:
32 sed -e '/ARPDDIR/d' -i Makefile
33 '';
34
35 outputs = [ "out" "dev" ];
36
37 makeFlags = [
38 "PREFIX=$(out)"
39 "SBINDIR=$(out)/sbin"
40 "DOCDIR=$(TMPDIR)/share/doc/${pname}" # Don't install docs
41 "HDRDIR=$(dev)/include/iproute2"
42 ];
43
44 buildFlags = [
45 "CONFDIR=/etc/iproute2"
46 ];
47
48 installFlags = [
49 "CONFDIR=$(out)/etc/iproute2"
50 ];
51
52 depsBuildBuild = [ buildPackages.stdenv.cc ]; # netem requires $HOSTCC
53 nativeBuildInputs = [ bison flex pkg-config ];
54 buildInputs = [ db iptables libelf libmnl ];
55
56 enableParallelBuilding = true;
57
58 passthru.updateScript = gitUpdater {
59 # No nicer place to find latest release.
60 url = "https://git.kernel.org/pub/scm/network/iproute2/iproute2.git";
61 rev-prefix = "v";
62 };
63
64 meta = with lib; {
65 homepage = "https://wiki.linuxfoundation.org/networking/iproute2";
66 description = "A collection of utilities for controlling TCP/IP networking and traffic control in Linux";
67 platforms = platforms.linux;
68 license = licenses.gpl2;
69 maintainers = with maintainers; [ primeos eelco fpletz globin ];
70 };
71}