nixpkgs/pkgs/development/tools/misc/lsof/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.8 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, buildPackages, ncurses }:
2016-10-04 23:27:47 +00:00
let dialect = with lib; last (splitString "-" stdenv.hostPlatform.system); in
2017-01-27 23:22:39 +00:00
2015-07-15 19:25:21 +00:00
stdenv.mkDerivation rec {
2019-08-28 22:17:25 +00:00
pname = "lsof";
2020-11-11 14:36:05 +00:00
version = "4.94.0";
2018-01-15 00:51:53 +00:00
depsBuildBuild = [ buildPackages.stdenv.cc ];
2016-10-04 23:27:47 +00:00
buildInputs = [ ncurses ];
2016-10-04 13:37:35 +00:00
2019-08-28 22:17:25 +00:00
src = fetchFromGitHub {
owner = "lsof-org";
repo = "lsof";
2019-09-08 23:38:31 +00:00
rev = version;
2020-11-11 14:36:05 +00:00
sha256 = "0yxv2jg6rnzys49lyrz9yjb4knamah4xvlqj596y6ix3vm4k3chp";
};
2019-08-28 22:17:25 +00:00
patches = [ ./no-build-info.patch ];
2018-04-16 22:58:07 +00:00
postPatch = lib.optionalString stdenv.hostPlatform.isMusl ''
2018-01-14 07:38:17 +00:00
substituteInPlace dialects/linux/dlsof.h --replace "defined(__UCLIBC__)" 1
'' + lib.optionalString stdenv.isDarwin ''
2018-04-16 22:58:07 +00:00
sed -i 's|lcurses|lncurses|g' Configure
2018-01-14 07:38:17 +00:00
'';
2017-01-27 23:22:39 +00:00
# Stop build scripts from searching global include paths
LSOF_INCLUDE = "${lib.getDev stdenv.cc.libc}/include";
2018-01-15 00:51:53 +00:00
configurePhase = "LINUX_CONF_CC=$CC_FOR_BUILD LSOF_CC=$CC LSOF_AR=\"$AR cr\" LSOF_RANLIB=$RANLIB ./Configure -n ${dialect}";
2016-10-04 23:27:47 +00:00
preBuild = ''
2017-01-27 23:22:39 +00:00
for filepath in $(find dialects/${dialect} -type f); do
sed -i "s,/usr/include,$LSOF_INCLUDE,g" $filepath
done
2016-10-04 23:27:47 +00:00
'';
installPhase = ''
2019-09-29 00:19:19 +00:00
# Fix references from man page https://github.com/lsof-org/lsof/issues/66
substituteInPlace Lsof.8 \
--replace ".so ./00DIALECTS" "" \
--replace ".so ./version" ".ds VN ${version}"
mkdir -p $out/bin $out/man/man8
2019-08-28 22:17:25 +00:00
cp Lsof.8 $out/man/man8/lsof.8
cp lsof $out/bin
'';
meta = with lib; {
2019-08-28 22:17:25 +00:00
homepage = "https://github.com/lsof-org/lsof";
description = "A tool to list open files";
longDescription = ''
List open files. Can show what process has opened some file,
socket (IPv6/IPv4/UNIX local), or partition (by opening a file
from it).
'';
maintainers = [ maintainers.dezgeg ];
platforms = platforms.unix;
license = licenses.purdueBsd;
};
}