mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-23 06:03:40 +00:00
72 lines
1.7 KiB
Nix
72 lines
1.7 KiB
Nix
{ lib
|
|
, buildGoModule
|
|
, fetchFromGitHub
|
|
, installShellFiles
|
|
, makeWrapper
|
|
, less
|
|
, xdg-utils
|
|
, testers
|
|
, runCommand
|
|
, stackit-cli
|
|
}:
|
|
|
|
buildGoModule rec {
|
|
pname = "stackit-cli";
|
|
version = "0.4.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "stackitcloud";
|
|
repo = "stackit-cli";
|
|
rev = "v${version}";
|
|
hash = "sha256-qujqRLXkQqUrpmyEkawPyEmCleXN43Wvv+sFwevVtqA=";
|
|
};
|
|
|
|
vendorHash = "sha256-SOX6jL7KX4FvYUyE3vyA8pjKwe4co073QZ1qRMGm3/Q=";
|
|
|
|
subPackages = [ "." ];
|
|
|
|
CGO_ENABLED = 0;
|
|
|
|
ldflags = [
|
|
"-s"
|
|
"-w"
|
|
"-X main.version=${version}"
|
|
];
|
|
|
|
nativeBuildInputs = [ installShellFiles makeWrapper ];
|
|
|
|
postInstall = ''
|
|
mv $out/bin/{${pname},stackit} # rename the binary
|
|
|
|
installShellCompletion --cmd stackit \
|
|
--bash <($out/bin/stackit completion bash) \
|
|
--zsh <($out/bin/stackit completion zsh) \
|
|
--fish <($out/bin/stackit completion fish)
|
|
# Ensure that all 3 completion scripts exist AND have content (should be kept for regression testing)
|
|
[ $(find $out/share -not -empty -type f | wc -l) -eq 3 ]
|
|
'';
|
|
|
|
postFixup = ''
|
|
wrapProgram $out/bin/stackit \
|
|
--suffix PATH : ${lib.makeBinPath [ less xdg-utils ]}
|
|
'';
|
|
|
|
nativeCheckInputs = [ less ];
|
|
|
|
passthru.tests = {
|
|
version = testers.testVersion {
|
|
package = stackit-cli;
|
|
command = "stackit --version";
|
|
};
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "CLI to manage STACKIT cloud services";
|
|
homepage = "https://github.com/stackitcloud/stackit-cli";
|
|
changelog = "https://github.com/stackitcloud/stackit-cli/releases/tag/v${version}";
|
|
license = licenses.asl20;
|
|
maintainers = with maintainers; [ DerRockWolf ];
|
|
mainProgram = "stackit";
|
|
};
|
|
}
|