1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 meson,
6 ninja,
7 pkg-config,
8 gettext,
9 libxslt,
10 docbook_xsl_ns,
11 libcap,
12 libidn2,
13 iproute2,
14 apparmorRulesFromClosure,
15}:
16
17stdenv.mkDerivation rec {
18 pname = "iputils";
19 version = "20250605";
20
21 src = fetchFromGitHub {
22 owner = pname;
23 repo = pname;
24 rev = version;
25 hash = "sha256-AJgNPIE90kALu4ihANELr9Dh28LhJ4camLksOIRV8Xo=";
26 };
27
28 outputs = [
29 "out"
30 "apparmor"
31 ];
32
33 # We don't have the required permissions inside the build sandbox:
34 # /build/source/build/ping/ping: socket: Operation not permitted
35 doCheck = false;
36
37 mesonFlags = [
38 "-DNO_SETCAP_OR_SUID=true"
39 "-Dsystemdunitdir=etc/systemd/system"
40 "-DINSTALL_SYSTEMD_UNITS=true"
41 "-DSKIP_TESTS=${lib.boolToString (!doCheck)}"
42 ]
43 # Disable idn usage w/musl (https://github.com/iputils/iputils/pull/111):
44 ++ lib.optional stdenv.hostPlatform.isMusl "-DUSE_IDN=false";
45
46 nativeBuildInputs = [
47 meson
48 ninja
49 pkg-config
50 gettext
51 libxslt.bin
52 docbook_xsl_ns
53 ];
54 buildInputs = [ libcap ] ++ lib.optional (!stdenv.hostPlatform.isMusl) libidn2;
55 nativeCheckInputs = [ iproute2 ];
56
57 postInstall = ''
58 mkdir $apparmor
59 cat >$apparmor/bin.ping <<EOF
60 include <tunables/global>
61 $out/bin/ping {
62 include <abstractions/base>
63 include <abstractions/consoles>
64 include <abstractions/nameservice>
65 include "${
66 apparmorRulesFromClosure { name = "ping"; } (
67 [ libcap ] ++ lib.optional (!stdenv.hostPlatform.isMusl) libidn2
68 )
69 }"
70 include <local/bin.ping>
71 capability net_raw,
72 network inet raw,
73 network inet6 raw,
74 mr $out/bin/ping,
75 r $out/share/locale/**,
76 r @{PROC}/@{pid}/environ,
77 }
78 EOF
79 '';
80
81 meta = with lib; {
82 homepage = "https://github.com/iputils/iputils";
83 changelog = "https://github.com/iputils/iputils/releases/tag/${version}";
84 description = "Set of small useful utilities for Linux networking";
85 longDescription = ''
86 A set of small useful utilities for Linux networking including:
87
88 - arping: send ARP REQUEST to a neighbour host
89 - clockdiff: measure clock difference between hosts
90 - ping: send ICMP ECHO_REQUEST to network hosts
91 - tracepath: traces path to a network host discovering MTU along this path
92 '';
93 license = with licenses; [
94 gpl2Plus
95 bsd3
96 ];
97 platforms = platforms.linux;
98 maintainers = with maintainers; [ ];
99 };
100}