broot: modernise, cleanup, use versionCheckHook

This commit is contained in:
Pol Dellaiera 2025-05-03 20:54:33 +02:00
parent 7f6a5a6ed9
commit f783f655af

View File

@ -4,23 +4,24 @@
rustPlatform,
fetchFromGitHub,
installShellFiles,
makeWrapper,
makeBinaryWrapper,
pkg-config,
libgit2,
zlib,
buildPackages,
versionCheckHook,
withClipboard ? true,
withTrash ? !stdenv.hostPlatform.isDarwin,
}:
rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage (finalAttrs: {
pname = "broot";
version = "1.46.3";
src = fetchFromGitHub {
owner = "Canop";
repo = "broot";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-MfBlJ7SokBKkAkmBSj4NsE2hKVqYeGN3z/xiq2VK3vU=";
};
@ -29,7 +30,7 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = [
installShellFiles
makeWrapper
makeBinaryWrapper
pkg-config
];
@ -43,13 +44,13 @@ rustPlatform.buildRustPackage rec {
buildFeatures = lib.optionals withTrash [ "trash" ] ++ lib.optionals withClipboard [ "clipboard" ];
RUSTONIG_SYSTEM_LIBONIG = true;
env.RUSTONIG_SYSTEM_LIBONIG = true;
postPatch = ''
# Fill the version stub in the man page. We can't fill the date
# stub reproducibly.
substitute man/page man/broot.1 \
--replace "#version" "${version}"
--replace-fail "#version" "${finalAttrs.version}"
'';
postInstall =
@ -84,16 +85,15 @@ rustPlatform.buildRustPackage rec {
'';
doInstallCheck = true;
installCheckPhase = ''
$out/bin/broot --version | grep "${version}"
'';
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
meta = with lib; {
description = "Interactive tree view, a fuzzy search, a balanced BFS descent and customizable commands";
homepage = "https://dystroy.org/broot/";
changelog = "https://github.com/Canop/broot/releases/tag/v${version}";
changelog = "https://github.com/Canop/broot/releases/tag/v${finalAttrs.version}";
maintainers = with maintainers; [ dywedir ];
license = with licenses; [ mit ];
mainProgram = "broot";
};
}
})