From f326911cb926d264d784186219f4608bf557170f Mon Sep 17 00:00:00 2001 From: Aaron Jheng Date: Mon, 6 Feb 2023 11:52:59 +0000 Subject: [PATCH] temporal-cli: combine temporal-cli and tctl --- .../cluster/temporal-cli/default.nix | 98 ++++++++++++++----- 1 file changed, 74 insertions(+), 24 deletions(-) diff --git a/pkgs/applications/networking/cluster/temporal-cli/default.nix b/pkgs/applications/networking/cluster/temporal-cli/default.nix index a78aaf4b56da..fb3268ab55a9 100644 --- a/pkgs/applications/networking/cluster/temporal-cli/default.nix +++ b/pkgs/applications/networking/cluster/temporal-cli/default.nix @@ -1,35 +1,85 @@ -{ lib, fetchFromGitHub, buildGoModule, testers, temporal-cli }: +{ lib, fetchFromGitHub, buildGoModule, installShellFiles, symlinkJoin }: -buildGoModule rec { +let + tctl-next = buildGoModule rec { + pname = "tctl-next"; + version = "0.8.0"; + + src = fetchFromGitHub { + owner = "temporalio"; + repo = "cli"; + rev = "v${version}"; + hash = "sha256-yQnFw3uYGKrTevGFVZNgkWwKCCWiGy0qwJJOmnMpTJQ="; + }; + + vendorHash = "sha256-ld59ADHnlgsCA2mzVhdq6Vb2aa9rApvFxs3NpHiCKxo="; + + nativeBuildInputs = [ installShellFiles ]; + + excludedPackages = [ "./cmd/docgen" ]; + + ldflags = [ + "-s" + "-w" + "-X github.com/temporalio/cli/headers.Version=${version}" + ]; + + preCheck = '' + export HOME=$(mktemp -d) + ''; + + postInstall = '' + installShellCompletion --cmd temporal \ + --bash <($out/bin/temporal completion bash) \ + --zsh <($out/bin/temporal completion zsh) + ''; + }; + + tctl = buildGoModule rec { + pname = "tctl"; + version = "1.18.0"; + + src = fetchFromGitHub { + owner = "temporalio"; + repo = "tctl"; + rev = "v${version}"; + hash = "sha256-LcBKkx3mcDOrGT6yJx98CSgxbwskqGPWqOzHWOu6cig="; + }; + + vendorHash = "sha256-BUYEeC5zli++OxVFgECJGqJkbDwglLppSxgo+4AqOb0="; + + nativeBuildInputs = [ installShellFiles ]; + + excludedPackages = [ "./cmd/copyright" ]; + + ldflags = [ "-s" "-w" ]; + + preCheck = '' + export HOME=$(mktemp -d) + ''; + + postInstall = '' + installShellCompletion --cmd tctl \ + --bash <($out/bin/tctl completion bash) \ + --zsh <($out/bin/tctl completion zsh) + ''; + }; +in +symlinkJoin rec { pname = "temporal-cli"; - version = "1.18.0"; + inherit (tctl) version; + name = "${pname}-${version}"; - src = fetchFromGitHub { - owner = "temporalio"; - repo = "tctl"; - rev = "v${version}"; - hash = "sha256-LcBKkx3mcDOrGT6yJx98CSgxbwskqGPWqOzHWOu6cig="; - }; - - vendorHash = "sha256-BUYEeC5zli++OxVFgECJGqJkbDwglLppSxgo+4AqOb0="; - - ldflags = [ "-s" "-w" ]; - - preCheck = '' - export HOME=$(mktemp -d) - ''; - - passthru.tests.version = testers.testVersion { - package = temporal-cli; - # the app writes a default config file at startup - command = "HOME=$(mktemp -d) ${meta.mainProgram} --version"; - }; + paths = [ + tctl-next + tctl + ]; meta = with lib; { description = "Temporal CLI"; homepage = "https://temporal.io"; license = licenses.mit; maintainers = with maintainers; [ aaronjheng ]; - mainProgram = "tctl"; + mainProgram = "temporal"; }; }