about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2024-03-27 11:16:30 +0100
committerGitHub <noreply@github.com>2024-03-27 11:16:30 +0100
commitda524b7072b238973ae8dd02b0d75f45261b806a (patch)
tree55fd46cf4e8e3583c9c6c491e198256cc5fcadb1
parente86a7374556a56627e36b5e6e7c27110b0e94d29 (diff)
parent971426ad4939fb978719606609e4c2e6a06f3675 (diff)
downloadnixlib-da524b7072b238973ae8dd02b0d75f45261b806a.tar
nixlib-da524b7072b238973ae8dd02b0d75f45261b806a.tar.gz
nixlib-da524b7072b238973ae8dd02b0d75f45261b806a.tar.bz2
nixlib-da524b7072b238973ae8dd02b0d75f45261b806a.tar.lz
nixlib-da524b7072b238973ae8dd02b0d75f45261b806a.tar.xz
nixlib-da524b7072b238973ae8dd02b0d75f45261b806a.tar.zst
nixlib-da524b7072b238973ae8dd02b0d75f45261b806a.zip
Merge pull request #297245 from DerRockWolf/add/stackit-cli
-rw-r--r--maintainers/maintainer-list.nix6
-rw-r--r--pkgs/by-name/st/stackit-cli/package.nix80
2 files changed, 86 insertions, 0 deletions
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index 3ae6ac2b02e2..6cb3adf29c25 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -4745,6 +4745,12 @@
     githubId = 4956158;
     name = "Robin Stumm";
   };
+  DerRockWolf = {
+    email = "git@rockwolf.eu";
+    github = "DerRockWolf";
+    githubId = 50499906;
+    name = "DerRockWolf";
+  };
   DerTim1 = {
     email = "tim.digel@active-group.de";
     github = "DerTim1";
diff --git a/pkgs/by-name/st/stackit-cli/package.nix b/pkgs/by-name/st/stackit-cli/package.nix
new file mode 100644
index 000000000000..cb6f2be4502d
--- /dev/null
+++ b/pkgs/by-name/st/stackit-cli/package.nix
@@ -0,0 +1,80 @@
+{ lib
+, buildGoModule
+, fetchFromGitHub
+, installShellFiles
+, makeWrapper
+, less
+, xdg-utils
+, testers
+, runCommand
+, stackit-cli
+}:
+
+buildGoModule rec {
+  pname = "stackit-cli";
+  version = "0.1.0-prerelease.2";
+
+  src = fetchFromGitHub {
+    owner = "stackitcloud";
+    repo = "stackit-cli";
+    rev = "v${version}";
+    hash = "sha256-GS3ZXarhXs1xuVmiLPMrrzXnO79R1+2va0x7N7CKNjQ=";
+  };
+
+  vendorHash = "sha256-Cill5hq8KVeKGRX2u9oIudi/s8XHIW5C8sgbTshrLY4=";
+
+  subPackages = [ "." ];
+
+  CGO_ENABLED = 0;
+
+  ldflags = [
+    "-s"
+    "-w"
+    "-X main.version=${version}"
+  ];
+
+  nativeBuildInputs = [ installShellFiles makeWrapper ];
+
+  preCheck = ''
+    export HOME=$TMPDIR # needed because the binary always creates a dir & config file
+  '';
+
+  postInstall = ''
+    export HOME=$TMPDIR # needed because the binary always creates a dir & config file
+    mv $out/bin/{${pname},stackit} # rename the binary
+
+    installShellCompletion --cmd stackit --bash <($out/bin/stackit completion bash)
+    installShellCompletion --cmd stackit --zsh <($out/bin/stackit completion zsh)
+    installShellCompletion --cmd stackit --fish <($out/bin/stackit completion fish)
+    # Use this instead, once https://github.com/stackitcloud/stackit-cli/issues/153 is fixed:
+    # 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 = "HOME=$TMPDIR 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";
+  };
+}