2024-03-17 15:31:37 +01:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
|
|
|
, makeWrapper
|
|
|
|
, less
|
|
|
|
, xdg-utils
|
|
|
|
, testers
|
|
|
|
, stackit-cli
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "stackit-cli";
|
2024-09-20 13:15:31 +02:00
|
|
|
version = "0.16.0";
|
2024-03-17 15:31:37 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "stackitcloud";
|
|
|
|
repo = "stackit-cli";
|
|
|
|
rev = "v${version}";
|
2024-09-20 13:15:31 +02:00
|
|
|
hash = "sha256-9s7F3pcamzwAESA/mKnCnSPpSmAX+L81fDoDpR71gzA=";
|
2024-03-17 15:31:37 +01:00
|
|
|
};
|
|
|
|
|
2024-09-20 13:15:31 +02:00
|
|
|
vendorHash = "sha256-QNi98VRy5BtML8jTxaDR3ZQfkXqjmfCf5IrcvGKE+rc=";
|
2024-03-17 15:31:37 +01:00
|
|
|
|
|
|
|
subPackages = [ "." ];
|
|
|
|
|
|
|
|
CGO_ENABLED = 0;
|
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X main.version=${version}"
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles makeWrapper ];
|
|
|
|
|
|
|
|
postInstall = ''
|
2024-08-21 00:56:55 +02:00
|
|
|
mv $out/bin/{stackit-cli,stackit} # rename the binary
|
2024-03-17 15:31:37 +01:00
|
|
|
|
2024-04-24 19:25:35 +02:00
|
|
|
installShellCompletion --cmd stackit \
|
|
|
|
--bash <($out/bin/stackit completion bash) \
|
|
|
|
--zsh <($out/bin/stackit completion zsh) \
|
|
|
|
--fish <($out/bin/stackit completion fish)
|
2024-03-17 15:31:37 +01:00
|
|
|
# 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;
|
2024-04-24 19:25:35 +02:00
|
|
|
command = "stackit --version";
|
2024-03-17 15:31:37 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
}
|