1{ lib, stdenv, fetchurl
2, buildPackages, bison, flex, pkg-config
3, db, iptables, libelf, libmnl
4, gitUpdater
5}:
6
7stdenv.mkDerivation rec {
8 pname = "iproute2";
9 version = "6.5.0";
10
11 src = fetchurl {
12 url = "mirror://kernel/linux/utils/net/${pname}/${pname}-${version}.tar.xz";
13 hash = "sha256-pwF5CF+huW08M7BAyAm3XitXVjrcUFpK0F4mCd83NGM=";
14 };
15
16 postPatch = ''
17 # Don't try to create /var/lib/arpd:
18 sed -e '/ARPDDIR/d' -i Makefile
19
20 substituteInPlace Makefile \
21 --replace "CC := gcc" "CC ?= $CC"
22 '';
23
24 outputs = [ "out" "dev" ];
25
26 makeFlags = [
27 "PREFIX=$(out)"
28 "SBINDIR=$(out)/sbin"
29 "DOCDIR=$(TMPDIR)/share/doc/${pname}" # Don't install docs
30 "HDRDIR=$(dev)/include/iproute2"
31 ] ++ lib.optionals stdenv.hostPlatform.isStatic [
32 "SHARED_LIBS=n"
33 # all build .so plugins:
34 "TC_CONFIG_NO_XT=y"
35 ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
36 "HOSTCC=$(CC_FOR_BUILD)"
37 ];
38
39 buildFlags = [
40 "CONFDIR=/etc/iproute2"
41 ];
42
43 installFlags = [
44 "CONFDIR=$(out)/etc/iproute2"
45 ];
46
47 depsBuildBuild = [ buildPackages.stdenv.cc ]; # netem requires $HOSTCC
48 nativeBuildInputs = [ bison flex pkg-config ];
49 buildInputs = [ db iptables libelf libmnl ];
50
51 enableParallelBuilding = true;
52
53 passthru.updateScript = gitUpdater {
54 # No nicer place to find latest release.
55 url = "https://git.kernel.org/pub/scm/network/iproute2/iproute2.git";
56 rev-prefix = "v";
57 };
58
59 meta = with lib; {
60 homepage = "https://wiki.linuxfoundation.org/networking/iproute2";
61 description = "A collection of utilities for controlling TCP/IP networking and traffic control in Linux";
62 platforms = platforms.linux;
63 license = licenses.gpl2;
64 maintainers = with maintainers; [ primeos eelco fpletz globin ];
65 };
66}