mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-19 23:21:27 +00:00
mole-cleaner: 1.31.0 -> 1.46.0 (#541583)
This commit is contained in:
@@ -4,32 +4,47 @@
|
||||
fetchFromGitHub,
|
||||
makeWrapper,
|
||||
coreutils,
|
||||
gnused,
|
||||
gawk,
|
||||
fd,
|
||||
gitUpdater,
|
||||
nix-update-script,
|
||||
versionCheckHook,
|
||||
writableTmpDirAsHomeHook,
|
||||
writeShellScript,
|
||||
}:
|
||||
|
||||
let
|
||||
duForTests = writeShellScript "mole-cleaner-du-for-tests" ''
|
||||
args=()
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
-I)
|
||||
shift
|
||||
args+=("--exclude=$1")
|
||||
;;
|
||||
*)
|
||||
args+=("$1")
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exec ${lib.getExe' coreutils "du"} "''${args[@]}"
|
||||
'';
|
||||
in
|
||||
buildGoModule (finalAttrs: {
|
||||
pname = "mole-cleaner";
|
||||
version = "1.31.0";
|
||||
__structuredAttrs = true;
|
||||
version = "1.46.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "tw93";
|
||||
repo = "Mole";
|
||||
tag = "V${finalAttrs.version}";
|
||||
hash = "sha256-dalmW3W/seGZreSWuYP7JN/nMUbs3WyDHzKU83EveeY=";
|
||||
hash = "sha256-rIoVXEz4K0RFb1ir1gRCyDw5euNwQvLS0GwBsJhuApE=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-LznLZ0NO8VBWP95ReAVORUMIDhh7/pgTY5mGNN2tND8=";
|
||||
vendorHash = "sha256-hLFlAy4AE1eNOxd4d75Mbo3ZKlwvNK7QV2DNVPd7NHc=";
|
||||
|
||||
subPackages = [
|
||||
"cmd/analyze"
|
||||
"cmd/status"
|
||||
];
|
||||
__structuredAttrs = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
@@ -39,59 +54,84 @@ buildGoModule (finalAttrs: {
|
||||
versionCheckHook
|
||||
writableTmpDirAsHomeHook
|
||||
coreutils
|
||||
gnused
|
||||
gawk
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
go build -p "$NIX_BUILD_CORES" -o analyze ./cmd/analyze
|
||||
go build -p "$NIX_BUILD_CORES" -o status ./cmd/status
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 mole $out/libexec/mole/mole
|
||||
install -Dm755 mo $out/libexec/mole/mo
|
||||
cp -r bin lib $out/libexec/mole/
|
||||
|
||||
mv $out/bin/analyze $out/libexec/mole/bin/analyze-go
|
||||
mv $out/bin/status $out/libexec/mole/bin/status-go
|
||||
install -Dm755 analyze $out/libexec/mole/bin/analyze-go
|
||||
install -Dm755 status $out/libexec/mole/bin/status-go
|
||||
|
||||
patchShebangs $out/libexec/mole
|
||||
|
||||
makeWrapper $out/libexec/mole/mole $out/bin/mole \
|
||||
--prefix PATH : ${
|
||||
lib.makeBinPath [
|
||||
fd
|
||||
coreutils
|
||||
gnused
|
||||
gawk
|
||||
]
|
||||
}
|
||||
makeWrapper $out/libexec/mole/mo $out/bin/mo \
|
||||
--prefix PATH : ${
|
||||
lib.makeBinPath [
|
||||
fd
|
||||
coreutils
|
||||
gnused
|
||||
gawk
|
||||
]
|
||||
}
|
||||
substituteInPlace $out/libexec/mole/mole \
|
||||
--replace-fail 'update_message="$(read_update_message_cache "$msg_cache")"' 'update_message=""'
|
||||
|
||||
mkdir -p $out/libexec/mole/nix-bin
|
||||
ln -s ${lib.getExe' coreutils "timeout"} $out/libexec/mole/nix-bin/timeout
|
||||
|
||||
makeWrapper $out/libexec/mole/mole $out/bin/mo \
|
||||
--run '
|
||||
case "$1" in
|
||||
update|remove)
|
||||
echo "mo $1 is unsupported for Nix-installed Mole; update or remove it through your Nix profile or configuration." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
export PATH=${
|
||||
lib.makeBinPath [
|
||||
fd
|
||||
]
|
||||
}:'"$out"'/libexec/mole/nix-bin:/usr/bin:/bin:''${PATH}
|
||||
'
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
# Keep buildGoModule's test behavior: tests can rely on their source paths.
|
||||
export GOFLAGS="''${GOFLAGS//-trimpath/}"
|
||||
mkdir -p "$TMPDIR/mole-test-bin"
|
||||
ln -s ${duForTests} "$TMPDIR/mole-test-bin/du"
|
||||
PATH="$TMPDIR/mole-test-bin:$PATH" go test ./...
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
versionCheckKeepEnvironment = [ "HOME" ];
|
||||
versionCheckKeepEnvironment = "HOME PATH";
|
||||
versionCheckProgram = "${placeholder "out"}/bin/mo";
|
||||
versionCheckProgramArg = "--version";
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
$out/bin/mole --help > /dev/null
|
||||
$out/bin/mo --help > /dev/null
|
||||
test -w "$HOME"
|
||||
test ! -e $out/bin/mole
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
passthru.updateScript = gitUpdater { rev-prefix = "V"; };
|
||||
passthru.updateScript = nix-update-script {
|
||||
extraArgs = [ "--version-regex=^V(.*)$" ];
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "CLI tool for cleaning and optimizing macOS systems";
|
||||
homepage = "https://github.com/tw93/Mole";
|
||||
changelog = "https://github.com/tw93/Mole/releases/tag/V${finalAttrs.version}";
|
||||
license = lib.licenses.mit;
|
||||
license = lib.licenses.gpl3Only;
|
||||
maintainers = with lib.maintainers; [ IanHollow ];
|
||||
mainProgram = "mole";
|
||||
mainProgram = "mo";
|
||||
platforms = lib.platforms.darwin;
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user