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