{ stdenv, fetchFromGitHub, lib, buildGoModule, }: let version = "1.30.0"; src = fetchFromGitHub { owner = "tw93"; repo = "Mole"; tag = "V${version}"; hash = "sha256-uo/wPKObL5i6A0i/1hmOjXCzlJkkrFsmZHvLoHmM8Ro="; }; goComponents = buildGoModule { pname = "mac-mole-go"; inherit version src; ldflags = [ "-s" "-w" "-X main.Version=${version}" ]; subPackages = [ "cmd/analyze" "cmd/status" ]; vendorHash = "sha256-oepnMZcaTB9u3h6S0jcP4W0pqNkDDgETVqDdCL0jarM="; }; in stdenv.mkDerivation (self: { pname = "mac-mole"; inherit version src; buildPhase = '' script_dir="$out/libexec" mkdir -p $out/bin $script_dir cp -r ./bin $script_dir cp -r ./lib $script_dir ln -s ${goComponents}/bin/analyze $script_dir/bin/analyze-go ln -s ${goComponents}/bin/status $script_dir/bin/status-go cp mole $out/bin ln -s $out/bin/mole $out/bin/mo substituteInPlace $out/bin/mole \ --replace 'SCRIPT_DIR="$(cd "$(dirname "''${BASH_SOURCE[0]}")" && pwd)"' "SCRIPT_DIR='$script_dir'" ''; meta = { description = "Deep clean and optimize your Mac"; homepage = "https://github.com/tw93/Mole"; licenses = lib.licenses.mit; mainProgram = "mole"; }; })