about summary refs log tree commit diff
path: root/pkgs/development/tools/kubeswitch/default.nix
blob: 64701124a1593465fd2ce1fe2e556f5ddb6d55db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  testers,
  kubeswitch,
  installShellFiles,
}:

buildGoModule rec {
  pname = "kubeswitch";
  version = "0.9.0";

  src = fetchFromGitHub {
    owner = "danielfoehrKn";
    repo = "kubeswitch";
    rev = version;
    hash = "sha256-0SY7JLFkhLEFcE1veqac9I9DZstXfxtnmSYIdDiVieg=";
  };

  vendorHash = null;

  subPackages = [ "cmd/main.go" ];

  ldflags = [
    "-s"
    "-w"
    "-X github.com/danielfoehrkn/kubeswitch/cmd/switcher.version=${version}"
    "-X github.com/danielfoehrkn/kubeswitch/cmd/switcher.buildDate=1970-01-01"
  ];

  nativeBuildInputs = [ installShellFiles ];

  postInstall = ''
    mv $out/bin/main $out/bin/switcher
    for shell in bash zsh fish; do
      $out/bin/switcher --cmd switcher completion $shell > switcher.$shell
      installShellCompletion --$shell switcher.$shell
    done
  '';

  passthru.tests.version = testers.testVersion { package = kubeswitch; };

  meta = {
    changelog = "https://github.com/danielfoehrKn/kubeswitch/releases/tag/${version}";
    description = "The kubectx for operators, a drop-in replacement for kubectx";
    license = lib.licenses.asl20;
    homepage = "https://github.com/danielfoehrKn/kubeswitch";
    maintainers = with lib.maintainers; [ bryanasdev000 ];
    mainProgram = "switcher";
  };
}