nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7 testers,
8 clusterctl,
9}:
10
11buildGoModule rec {
12 pname = "clusterctl";
13 version = "1.12.2";
14
15 src = fetchFromGitHub {
16 owner = "kubernetes-sigs";
17 repo = "cluster-api";
18 rev = "v${version}";
19 hash = "sha256-AaGJhdBTyCxUK+qm++McS6rFlgAdv/7SjQHvaNRn6YU=";
20 };
21
22 vendorHash = "sha256-3dh9Y8R4OeUayyqNyrvUcrnSi/4s9x6oMrAADXR5rnw=";
23
24 subPackages = [ "cmd/clusterctl" ];
25
26 nativeBuildInputs = [ installShellFiles ];
27
28 ldflags =
29 let
30 t = "sigs.k8s.io/cluster-api/version";
31 in
32 [
33 "-X ${t}.gitMajor=${lib.versions.major version}"
34 "-X ${t}.gitMinor=${lib.versions.minor version}"
35 "-X ${t}.gitVersion=v${version}"
36 ];
37
38 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
39 # errors attempting to write config to read-only $HOME
40 export HOME=$TMPDIR
41
42 installShellCompletion --cmd clusterctl \
43 --bash <($out/bin/clusterctl completion bash) \
44 --fish <($out/bin/clusterctl completion fish) \
45 --zsh <($out/bin/clusterctl completion zsh)
46 '';
47
48 passthru.tests.version = testers.testVersion {
49 package = clusterctl;
50 command = "HOME=$TMPDIR clusterctl version";
51 version = "v${version}";
52 };
53
54 meta = {
55 changelog = "https://github.com/kubernetes-sigs/cluster-api/releases/tag/${src.rev}";
56 description = "Kubernetes cluster API tool";
57 mainProgram = "clusterctl";
58 homepage = "https://cluster-api.sigs.k8s.io/";
59 license = lib.licenses.asl20;
60 maintainers = with lib.maintainers; [ qjoly ];
61 };
62}