mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-09-11 15:08:33 +01:00
6a9beaf893
This focuses on Rust packages, since the most commonly used argument parser library (clap/structopt) makes the following pattern natural and thus common: postInstall = '' installShellCompletion --cmd foo \ --bash <($out/bin/foo completion bash) \ … This commit just guards those with lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) splitting the string where unrelated actions are performed.
51 lines
1.3 KiB
Nix
51 lines
1.3 KiB
Nix
{ lib
|
|
, rustPlatform
|
|
, fetchFromGitHub
|
|
, installShellFiles
|
|
, stdenv
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
pname = "snazy";
|
|
version = "0.52.17";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "chmouel";
|
|
repo = pname;
|
|
rev = version;
|
|
hash = "sha256-0r5xhmU9a9I+q24mjJ+C4EKK1Nw/67YThuBFibAx3Dw=";
|
|
};
|
|
|
|
cargoHash = "sha256-ljYsF5lBRqiTqx9nta5h/75052GWOBJ9uJnqZkWJvwI=";
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
installShellCompletion --cmd snazy \
|
|
--bash <($out/bin/snazy --shell-completion bash) \
|
|
--fish <($out/bin/snazy --shell-completion fish) \
|
|
--zsh <($out/bin/snazy --shell-completion zsh)
|
|
'';
|
|
|
|
doInstallCheck = true;
|
|
installCheckPhase = ''
|
|
runHook preInstallCheck
|
|
$out/bin/snazy --help
|
|
$out/bin/snazy --version | grep "snazy ${version}"
|
|
runHook postInstallCheck
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Snazzy json log viewer";
|
|
mainProgram = "snazy";
|
|
longDescription = ''
|
|
Snazy is a simple tool to parse json logs and output them in a nice format
|
|
with nice colors.
|
|
'';
|
|
homepage = "https://github.com/chmouel/snazy/";
|
|
changelog = "https://github.com/chmouel/snazy/releases/tag/${src.rev}";
|
|
license = licenses.asl20;
|
|
maintainers = with maintainers; [ figsoda jk ];
|
|
};
|
|
}
|