nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 testers,
7 installShellFiles,
8}:
9
10buildGoModule (finalAttrs: {
11 pname = "harbor-cli";
12 version = "0.0.16";
13
14 src = fetchFromGitHub {
15 owner = "goharbor";
16 repo = "harbor-cli";
17 tag = "v${finalAttrs.version}";
18 hash = "sha256-bU42N2+zyOqdiJFbgaqcxsApdslQFOleythDE6hs8sY=";
19 };
20
21 vendorHash = "sha256-qTaXIkZ1g7jsPV4IkduIS6REIhs9JJcS2mOg3V77DTg=";
22
23 excludedPackages = [
24 "dagger"
25 "doc"
26 ];
27
28 nativeBuildInputs = [ installShellFiles ];
29
30 ldflags = [
31 "-s"
32 "-w"
33 "-X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.Version=${finalAttrs.version}"
34 ];
35
36 doCheck = false; # Network required
37
38 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
39 export HOME="$(mktemp -d)"
40
41 installShellCompletion --cmd harbor \
42 --bash <($out/bin/harbor completion bash) \
43 --fish <($out/bin/harbor completion fish) \
44 --zsh <($out/bin/harbor completion zsh)
45 '';
46
47 passthru.tests.version = testers.testVersion {
48 package = finalAttrs.finalPackage;
49 command = "HOME=\"$(mktemp -d)\" harbor version";
50 };
51
52 meta = {
53 homepage = "https://github.com/goharbor/harbor-cli";
54 description = "Command-line tool facilitates seamless interaction with the Harbor container registry";
55 changelog = "https://github.com/goharbor/harbor-cli/releases/tag/v${finalAttrs.version}";
56 license = lib.licenses.asl20;
57 maintainers = with lib.maintainers; [ aaronjheng ];
58 mainProgram = "harbor";
59 };
60})