1{ stdenv, fetchFromGitHub, fetchpatch
2, libxslt, docbook_xsl, docbook_xml_dtd_44
3, libcap, nettle, libidn2, openssl
4}:
5
6with stdenv.lib;
7
8let
9 time = "20180629";
10 # ninfod probably could build on cross, but the Makefile doesn't pass --host
11 # etc to the sub configure...
12 withNinfod = stdenv.hostPlatform == stdenv.buildPlatform;
13 sunAsIsLicense = {
14 fullName = "AS-IS, SUN MICROSYSTEMS license";
15 url = "https://github.com/iputils/iputils/blob/s${time}/rdisc.c";
16 };
17in stdenv.mkDerivation {
18 name = "iputils-${time}";
19
20 src = fetchFromGitHub {
21 owner = "iputils";
22 repo = "iputils";
23 rev = "s${time}";
24 sha256 = "19rpl48pjgmyqlm4h7sml5gy7yg4cxciadxcs24q1zj40c05jls0";
25 };
26
27 patches = [
28 (fetchpatch {
29 name = "dont-hardcode-the-location-of-xsltproc.patch";
30 url = "https://github.com/iputils/iputils/commit/d0ff83e87ea9064d9215a18e93076b85f0f9e828.patch";
31 sha256 = "05wrwf0bfmax69bsgzh3b40n7rvyzw097j8z5ix0xsg0kciygjvx";
32 })
33 ];
34
35 prePatch = ''
36 substituteInPlace doc/custom-man.xsl \
37 --replace "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" "${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl"
38 for xmlFile in doc/*.xml; do
39 substituteInPlace $xmlFile \
40 --replace "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" "${docbook_xml_dtd_44}/xml/dtd/docbook/docbookx.dtd"
41 done
42 '';
43
44 # Disable idn usage w/musl: https://github.com/iputils/iputils/pull/111
45 makeFlags = optional stdenv.hostPlatform.isMusl "USE_IDN=no";
46
47 nativeBuildInputs = [ libxslt.bin ];
48 buildInputs = [ libcap nettle ]
49 ++ optional (!stdenv.hostPlatform.isMusl) libidn2
50 ++ optional withNinfod openssl; # TODO: Build with nettle
51
52 buildFlags = "man all" + optionalString withNinfod " ninfod";
53
54 installPhase = ''
55 mkdir -p $out/bin
56 mkdir -p $out/share/man/man8
57
58 for tool in arping clockdiff ping rarpd rdisc tftpd tracepath traceroute6; do
59 cp $tool $out/bin/
60 cp doc/$tool.8 $out/share/man/man8/
61 done
62
63 # TODO: Requires kernel module pg3
64 cp ipg $out/bin/
65 cp doc/pg3.8 $out/share/man/man8/
66 '' + optionalString withNinfod ''
67 cp ninfod/ninfod $out/bin/
68 cp doc/ninfod.8 $out/share/man/man8/
69 '';
70
71 meta = {
72 homepage = https://github.com/iputils/iputils;
73 description = "A set of small useful utilities for Linux networking";
74 license = with licenses; [ gpl2Plus bsd3 sunAsIsLicense ];
75 platforms = platforms.linux;
76 maintainers = with maintainers; [ primeos lheckemann ];
77 };
78}