1{ stdenv, lib, fetchurl, ncurses, perl, help2man
2, apparmorRulesFromClosure
3, libxcrypt
4}:
5
6stdenv.mkDerivation rec {
7 pname = "inetutils";
8 version = "2.4";
9
10 src = fetchurl {
11 url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
12 sha256 = "sha256-F4nWsbGlff4qere1M+6fXf2cv1tZuxuzwmEu0I0PaLI=";
13 };
14
15 outputs = ["out" "apparmor"];
16
17 patches = [
18 # https://git.congatec.com/yocto/meta-openembedded/commit/3402bfac6b595c622e4590a8ff5eaaa854e2a2a3
19 ./inetutils-1_9-PATH_PROCNET_DEV.patch
20 ];
21
22 strictDeps = true;
23 nativeBuildInputs = [ help2man perl /* for `whois' */ ];
24 buildInputs = [ ncurses /* for `talk' */ libxcrypt ];
25
26 # Don't use help2man if cross-compiling
27 # https://lists.gnu.org/archive/html/bug-sed/2017-01/msg00001.html
28 # https://git.congatec.com/yocto/meta-openembedded/blob/3402bfac6b595c622e4590a8ff5eaaa854e2a2a3/meta-networking/recipes-connectivity/inetutils/inetutils_1.9.1.bb#L44
29 preConfigure = let
30 isCross = stdenv.hostPlatform != stdenv.buildPlatform;
31 in lib.optionalString isCross ''
32 export HELP2MAN=true
33 '';
34
35 configureFlags = [ "--with-ncurses-include-dir=${ncurses.dev}/include" ]
36 ++ lib.optionals stdenv.hostPlatform.isMusl [ # Musl doesn't define rcmd
37 "--disable-rcp"
38 "--disable-rsh"
39 "--disable-rlogin"
40 "--disable-rexec"
41 ] ++ lib.optional stdenv.isDarwin "--disable-servers";
42
43 # Test fails with "UNIX socket name too long", probably because our
44 # $TMPDIR is too long.
45 doCheck = false;
46
47 installFlags = [ "SUIDMODE=" ];
48
49 postInstall = ''
50 mkdir $apparmor
51 cat >$apparmor/bin.ping <<EOF
52 $out/bin/ping {
53 include <abstractions/base>
54 include <abstractions/consoles>
55 include <abstractions/nameservice>
56 include "${apparmorRulesFromClosure { name = "ping"; } [stdenv.cc.libc]}"
57 include <local/bin.ping>
58 capability net_raw,
59 network inet raw,
60 network inet6 raw,
61 mr $out/bin/ping,
62 }
63 EOF
64 '';
65
66 meta = with lib; {
67 description = "Collection of common network programs";
68
69 longDescription =
70 '' The GNU network utilities suite provides the
71 following tools: ftp(d), hostname, ifconfig, inetd, logger, ping, rcp,
72 rexec(d), rlogin(d), rsh(d), syslogd, talk(d), telnet(d), tftp(d),
73 traceroute, uucpd, and whois.
74 '';
75
76 homepage = "https://www.gnu.org/software/inetutils/";
77 license = licenses.gpl3Plus;
78
79 maintainers = with maintainers; [ matthewbauer ];
80 platforms = platforms.unix;
81 };
82}