1{ stdenv, fetchurl }: 2 3stdenv.mkDerivation rec { 4 name = "lsof-${version}"; 5 version = "4.89"; 6 7 src = fetchurl { 8 urls = 9 ["ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_${version}.tar.bz2"] 10 ++ map ( 11 # the tarball is moved after new version is released 12 isOld: "ftp://sunsite.ualberta.ca/pub/Mirror/lsof/" 13 + "${stdenv.lib.optionalString isOld "OLD/"}lsof_${version}.tar.bz2" 14 ) [ false true ]; 15 sha256 = "061p18v0mhzq517791xkjs8a5dfynq1418a1mwxpji69zp2jzb41"; 16 }; 17 18 unpackPhase = "tar xvjf $src; cd lsof_*; tar xvf lsof_*.tar; sourceRoot=$( echo lsof_*/); "; 19 20 preBuild = "sed -i Makefile -e 's/^CFGF=/& -DHASIPv6=1/;';"; 21 22 configurePhase = if stdenv.isDarwin 23 then "./Configure -n darwin;" 24 else "./Configure -n linux;"; 25 26 installPhase = '' 27 mkdir -p $out/bin $out/man/man8 28 cp lsof.8 $out/man/man8/ 29 cp lsof $out/bin 30 ''; 31 32 meta = { 33 homepage = ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/; 34 description = "A tool to list open files"; 35 longDescription = '' 36 List open files. Can show what process has opened some file, 37 socket (IPv6/IPv4/UNIX local), or partition (by opening a file 38 from it). 39 ''; 40 maintainers = [ stdenv.lib.maintainers.mornfall ]; 41 }; 42}