15 dialect = lib.last (lib.splitString "-" stdenv.hostPlatform.system);
18 stdenv.mkDerivation rec {
22 src = fetchFromGitHub {
26 hash = "sha256-JyvQV/JOMaL/3jUr6O0YIzJU/JcXVR65CJf5ip7334w=";
31 patchShebangs --build lib/dialects/*/Mksrc
32 # Do not re-build version.h in every 'make' to allow nuke-refs below.
33 # We remove phony 'FRC' target that forces rebuilds:
34 # 'version.h: FRC ...' is translated to 'version.h: ...'.
35 sed -i lib/dialects/*/Makefile -e 's/version.h:\s*FRC/version.h:/'
37 # help Configure find libproc.h in $SDKROOT
38 + lib.optionalString stdenv.hostPlatform.isDarwin ''
39 sed -i -e 's|lcurses|lncurses|g' \
40 -e "s|/Library.*/MacOSX.sdk/|\"$SDKROOT\"/|" Configure
43 depsBuildBuild = [ buildPackages.stdenv.cc ];
50 buildInputs = [ ncurses ];
52 # Stop build scripts from searching global include paths
53 LSOF_INCLUDE = "${lib.getDev stdenv.cc.libc}/include";
56 genericFlags = "LSOF_CC=$CC LSOF_AR=\"$AR cr\" LSOF_RANLIB=$RANLIB";
57 linuxFlags = lib.optionalString stdenv.hostPlatform.isLinux "LINUX_CONF_CC=$CC_FOR_BUILD";
58 freebsdFlags = lib.optionalString stdenv.hostPlatform.isFreeBSD "FREEBSD_SYS=${freebsd.sys.src}/sys";
60 "${genericFlags} ${linuxFlags} ${freebsdFlags} ./Configure -n ${dialect}";
63 for filepath in $(find dialects/${dialect} -type f); do
64 sed -i "s,/usr/include,$LSOF_INCLUDE,g" $filepath
67 # Wipe out development-only flags from CFLAGS embedding
73 # Fix references from man page https://github.com/lsof-org/lsof/issues/66
74 substituteInPlace Lsof.8 \
75 --replace ".so ./00DIALECTS" "" \
76 --replace ".so ./version" ".ds VN ${version}"
77 mkdir -p $out/bin $out/man/man8
78 cp Lsof.8 $out/man/man8/lsof.8
83 homepage = "https://github.com/lsof-org/lsof";
84 description = "Tool to list open files";
87 List open files. Can show what process has opened some file,
88 socket (IPv6/IPv4/UNIX local), or partition (by opening a file
91 license = lib.licenses.purdueBsd;
92 maintainers = with lib.maintainers; [ dezgeg ];
93 platforms = lib.platforms.unix;