Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 buildGoModule, 4 fetchFromGitHub, 5 installShellFiles, 6 makeWrapper, 7 less, 8 xdg-utils, 9 testers, 10 stackit-cli, 11}: 12 13buildGoModule rec { 14 pname = "stackit-cli"; 15 version = "0.37.3"; 16 17 src = fetchFromGitHub { 18 owner = "stackitcloud"; 19 repo = "stackit-cli"; 20 rev = "v${version}"; 21 hash = "sha256-nyNASYpZvao194rlKSyxNa74Ezo5CwiESNj54uBgUL4="; 22 }; 23 24 vendorHash = "sha256-iWGRFjCvXm03GRnmQlscP5Y5di9W4lW3jotyhDcE/x4="; 25 26 subPackages = [ "." ]; 27 28 env.CGO_ENABLED = 0; 29 30 ldflags = [ 31 "-s" 32 "-w" 33 "-X main.version=${version}" 34 ]; 35 36 nativeBuildInputs = [ 37 installShellFiles 38 makeWrapper 39 ]; 40 41 postInstall = '' 42 mv $out/bin/{stackit-cli,stackit} # rename the binary 43 44 installShellCompletion --cmd stackit \ 45 --bash <($out/bin/stackit completion bash) \ 46 --zsh <($out/bin/stackit completion zsh) \ 47 --fish <($out/bin/stackit completion fish) 48 # Ensure that all 3 completion scripts exist AND have content (should be kept for regression testing) 49 [ $(find $out/share -not -empty -type f | wc -l) -eq 3 ] 50 ''; 51 52 postFixup = '' 53 wrapProgram $out/bin/stackit \ 54 --suffix PATH : ${ 55 lib.makeBinPath [ 56 less 57 xdg-utils 58 ] 59 } 60 ''; 61 62 nativeCheckInputs = [ less ]; 63 64 passthru.tests = { 65 version = testers.testVersion { 66 package = stackit-cli; 67 command = "stackit --version"; 68 }; 69 }; 70 71 meta = { 72 description = "CLI to manage STACKIT cloud services"; 73 homepage = "https://github.com/stackitcloud/stackit-cli"; 74 changelog = "https://github.com/stackitcloud/stackit-cli/releases/tag/v${version}"; 75 license = lib.licenses.asl20; 76 maintainers = with lib.maintainers; [ DerRockWolf ]; 77 mainProgram = "stackit"; 78 }; 79}