at 23.05-pre 1.9 kB view raw
1{ lib, stdenv, fetchFromGitHub, buildPackages, perl, which, ncurses }: 2 3let 4 dialect = with lib; last (splitString "-" stdenv.hostPlatform.system); 5in 6 7stdenv.mkDerivation rec { 8 pname = "lsof"; 9 version = "4.96.4"; 10 11 src = fetchFromGitHub { 12 owner = "lsof-org"; 13 repo = "lsof"; 14 rev = version; 15 sha256 = "sha256-S+8KizjayqeiWsMySWjRoZQf7ODCjdMq5ULoetOdYiA="; 16 }; 17 18 patches = [ 19 ./no-build-info.patch 20 ]; 21 22 postPatch = lib.optionalString stdenv.hostPlatform.isMusl '' 23 substituteInPlace dialects/linux/dlsof.h --replace "defined(__UCLIBC__)" 1 24 '' + lib.optionalString stdenv.isDarwin '' 25 sed -i 's|lcurses|lncurses|g' Configure 26 ''; 27 28 depsBuildBuild = [ buildPackages.stdenv.cc ]; 29 nativeBuildInputs = [ perl which ]; 30 buildInputs = [ ncurses ]; 31 32 # Stop build scripts from searching global include paths 33 LSOF_INCLUDE = "${lib.getDev stdenv.cc.libc}/include"; 34 configurePhase = "LINUX_CONF_CC=$CC_FOR_BUILD LSOF_CC=$CC LSOF_AR=\"$AR cr\" LSOF_RANLIB=$RANLIB ./Configure -n ${dialect}"; 35 36 preBuild = '' 37 for filepath in $(find dialects/${dialect} -type f); do 38 sed -i "s,/usr/include,$LSOF_INCLUDE,g" $filepath 39 done 40 ''; 41 42 installPhase = '' 43 # Fix references from man page https://github.com/lsof-org/lsof/issues/66 44 substituteInPlace Lsof.8 \ 45 --replace ".so ./00DIALECTS" "" \ 46 --replace ".so ./version" ".ds VN ${version}" 47 mkdir -p $out/bin $out/man/man8 48 cp Lsof.8 $out/man/man8/lsof.8 49 cp lsof $out/bin 50 ''; 51 52 meta = with lib; { 53 homepage = "https://github.com/lsof-org/lsof"; 54 description = "A tool to list open files"; 55 longDescription = '' 56 List open files. Can show what process has opened some file, 57 socket (IPv6/IPv4/UNIX local), or partition (by opening a file 58 from it). 59 ''; 60 license = licenses.purdueBsd; 61 maintainers = with maintainers; [ dezgeg ]; 62 platforms = platforms.unix; 63 }; 64}