temporal-cli: combine temporal-cli and tctl

This commit is contained in:
Aaron Jheng 2023-02-06 11:52:59 +00:00
parent a7eb77e921
commit f326911cb9
No known key found for this signature in database
GPG key ID: F6A547A869D050A3

View file

@ -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";
};
}