nixpkgs/pkgs/by-name/us/usage/package.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.3 KiB
Nix
Raw Normal View History

2024-09-23 14:13:13 +02:00
{
lib,
stdenv,
2024-09-23 14:13:13 +02:00
rustPlatform,
fetchFromGitHub,
installShellFiles,
2024-09-23 14:13:13 +02:00
nix-update-script,
usage,
testers,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "usage";
version = "2.1.1";
2024-09-23 14:13:13 +02:00
src = fetchFromGitHub {
owner = "jdx";
repo = "usage";
tag = "v${finalAttrs.version}";
hash = "sha256-aMO/3geF1iFnMi0ZqBdnikp/Qh25vqpeaxdTiQtt5yI=";
2024-09-23 14:13:13 +02:00
};
cargoHash = "sha256-0NQZtT3xz4MaqY8ehKzy/cpDJlE5eWIixi3IropK11w=";
postPatch = ''
substituteInPlace ./examples/mounted.sh \
--replace-fail '/usr/bin/env -S usage' "$(pwd)/target/${stdenv.targetPlatform.rust.rustcTargetSpec}/release/usage"
'';
nativeBuildInputs = [ installShellFiles ];
postInstall = ''
installShellCompletion --cmd usage \
--bash <($out/bin/usage --completions bash) \
--fish <($out/bin/usage --completions fish) \
--zsh <($out/bin/usage --completions zsh)
'';
2024-09-23 14:13:13 +02:00
passthru = {
updateScript = nix-update-script { };
tests.version = testers.testVersion { package = usage; };
};
meta = {
homepage = "https://usage.jdx.dev";
description = "Specification for CLIs";
changelog = "https://github.com/jdx/usage/releases/tag/v${finalAttrs.version}";
2024-09-23 14:13:13 +02:00
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ konradmalik ];
mainProgram = "usage";
};
})