From 1efb2c37f15855527555cca6fa326bb98a629b7d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 22 Jul 2022 15:22:59 -0400 Subject: [PATCH] Add fuckport --- systems/darwin.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/systems/darwin.nix b/systems/darwin.nix index 6f78e3b..318c5bf 100644 --- a/systems/darwin.nix +++ b/systems/darwin.nix @@ -20,6 +20,21 @@ rosettaPkgs.idris2 #rosettaPkgs.coq # (rosettaPkgs.haskellPackages.callHackage "agda-language-server" "0.2.1" { }) + + # Kill the process with the port open + # Used only to kill stale ghc. + (pkgs.writeShellApplication { + name = "fuckport"; + runtimeInputs = [ jc jq ]; + text = '' + lsof -i :"$1" + THEPID=$(lsof -i :"$1" | jc --lsof 2> /dev/null | jq '.[].pid') + echo "KILL $THEPID ?" + read -r + kill "$THEPID" + ''; + }) + ]; nix = {