at 23.05-pre 87 lines 2.4 kB view raw
1{ lib, stdenv, fetchFromGitHub 2, meson, ninja, pkg-config, gettext, libxslt, docbook_xsl_ns 3, libcap, libidn2 4, iproute2 5, apparmorRulesFromClosure 6}: 7 8let 9 version = "20211215"; 10 sunAsIsLicense = { 11 fullName = "AS-IS, SUN MICROSYSTEMS license"; 12 url = "https://github.com/iputils/iputils/blob/s${version}/rdisc.c"; 13 }; 14in stdenv.mkDerivation rec { 15 pname = "iputils"; 16 inherit version; 17 18 src = fetchFromGitHub { 19 owner = pname; 20 repo = pname; 21 rev = version; 22 sha256 = "1vzdch1xi2x2j8mvnsr4wwwh7kdkgf926xafw5kkb74yy1wac5qv"; 23 }; 24 25 outputs = ["out" "apparmor"]; 26 27 # We don't have the required permissions inside the build sandbox: 28 # /build/source/build/ping/ping: socket: Operation not permitted 29 doCheck = false; 30 31 mesonFlags = [ 32 "-DBUILD_RARPD=true" 33 "-DNO_SETCAP_OR_SUID=true" 34 "-Dsystemdunitdir=etc/systemd/system" 35 "-DINSTALL_SYSTEMD_UNITS=true" 36 "-DSKIP_TESTS=${lib.boolToString (!doCheck)}" 37 ] 38 # Disable idn usage w/musl (https://github.com/iputils/iputils/pull/111): 39 ++ lib.optional stdenv.hostPlatform.isMusl "-DUSE_IDN=false"; 40 41 nativeBuildInputs = [ meson ninja pkg-config gettext libxslt.bin docbook_xsl_ns ]; 42 buildInputs = [ libcap ] 43 ++ lib.optional (!stdenv.hostPlatform.isMusl) libidn2; 44 checkInputs = [ iproute2 ]; 45 46 postInstall = '' 47 mkdir $apparmor 48 cat >$apparmor/bin.ping <<EOF 49 include <tunables/global> 50 $out/bin/ping { 51 include <abstractions/base> 52 include <abstractions/consoles> 53 include <abstractions/nameservice> 54 include "${apparmorRulesFromClosure { name = "ping"; } 55 ([libcap] ++ lib.optional (!stdenv.hostPlatform.isMusl) libidn2)}" 56 include <local/bin.ping> 57 capability net_raw, 58 network inet raw, 59 network inet6 raw, 60 mr $out/bin/ping, 61 r $out/share/locale/**, 62 r @{PROC}/@{pid}/environ, 63 } 64 EOF 65 ''; 66 67 meta = with lib; { 68 description = "A set of small useful utilities for Linux networking"; 69 inherit (src.meta) homepage; 70 changelog = "https://github.com/iputils/iputils/releases/tag/s${version}"; 71 license = with licenses; [ gpl2Plus bsd3 sunAsIsLicense ]; 72 platforms = platforms.linux; 73 maintainers = with maintainers; [ primeos lheckemann ]; 74 75 longDescription = '' 76 A set of small useful utilities for Linux networking including: 77 78 arping 79 clockdiff 80 ninfod 81 ping 82 rarpd 83 rdisc 84 tracepath 85 ''; 86 }; 87}