nixos-config/packages/fuckport.nix
Sridhar Ratnakumar 690b461868 fuckport: add desc
2024-03-06 08:54:12 -05:00

19 lines
451 B
Nix

{ writeShellApplication, jc, jq, ... }:
writeShellApplication {
name = "fuckport";
runtimeInputs = [ jc jq ];
meta.description = ''
Kill the process with the port open
Used only to kill stale ghc.
'';
# FIXME: This doesn't work when lsof returns *multiple* processes.
text = ''
lsof -i :"$1"
THEPID=$(lsof -i :"$1" | jc --lsof 2> /dev/null | jq '.[].pid')
echo "KILL $THEPID ?"
read -r
kill "$THEPID"
'';
}