anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / applications / networking / cluster / helm / default.nix
blob2f3275b59bfbdb08d3bf2adfc3c7216a98517a70
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   installShellFiles,
6   testers,
7   kubernetes-helm,
8 }:
10 buildGoModule rec {
11   pname = "kubernetes-helm";
12   version = "3.16.3";
14   src = fetchFromGitHub {
15     owner = "helm";
16     repo = "helm";
17     rev = "v${version}";
18     sha256 = "sha256-Uxb3nDcCTD61KHSon02eJJyj1MlJex/SmpOEIELdeMo=";
19   };
20   vendorHash = "sha256-4RKNNKUPLUv5bYde6pTL8u5/KXzN0Ai8n4fS9mbiZgw=";
22   subPackages = [ "cmd/helm" ];
23   ldflags = [
24     "-w"
25     "-s"
26     "-X helm.sh/helm/v3/internal/version.version=v${version}"
27     "-X helm.sh/helm/v3/internal/version.gitCommit=${src.rev}"
28   ];
30   preBuild = ''
31     # set k8s version to client-go version, to match upstream
32     K8S_MODULES_VER="$(go list -f '{{.Version}}' -m k8s.io/client-go)"
33     K8S_MODULES_MAJOR_VER="$(($(cut -d. -f1 <<<"$K8S_MODULES_VER") + 1))"
34     K8S_MODULES_MINOR_VER="$(cut -d. -f2 <<<"$K8S_MODULES_VER")"
35     old_ldflags="''${ldflags}"
36     ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/lint/rules.k8sVersionMajor=''${K8S_MODULES_MAJOR_VER}"
37     ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/lint/rules.k8sVersionMinor=''${K8S_MODULES_MINOR_VER}"
38     ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/chartutil.k8sVersionMajor=''${K8S_MODULES_MAJOR_VER}"
39     ldflags="''${ldflags} -X helm.sh/helm/v3/pkg/chartutil.k8sVersionMinor=''${K8S_MODULES_MINOR_VER}"
40   '';
42   __darwinAllowLocalNetworking = true;
44   preCheck = ''
45     # restore ldflags for tests
46     ldflags="''${old_ldflags}"
48     # skipping version tests because they require dot git directory
49     substituteInPlace cmd/helm/version_test.go \
50       --replace "TestVersion" "SkipVersion"
51     # skipping plugin tests
52     substituteInPlace cmd/helm/plugin_test.go \
53       --replace "TestPluginDynamicCompletion" "SkipPluginDynamicCompletion" \
54       --replace "TestLoadPlugins" "SkipLoadPlugins"
55     substituteInPlace cmd/helm/helm_test.go \
56       --replace "TestPluginExitCode" "SkipPluginExitCode"
57   '';
59   nativeBuildInputs = [ installShellFiles ];
60   postInstall = ''
61     $out/bin/helm completion bash > helm.bash
62     $out/bin/helm completion zsh > helm.zsh
63     $out/bin/helm completion fish > helm.fish
64     installShellCompletion helm.{bash,zsh,fish}
65   '';
67   passthru.tests.version = testers.testVersion {
68     package = kubernetes-helm;
69     command = "helm version";
70     version = "v${version}";
71   };
73   meta = with lib; {
74     homepage = "https://github.com/kubernetes/helm";
75     description = "Package manager for kubernetes";
76     mainProgram = "helm";
77     license = licenses.asl20;
78     maintainers = with maintainers; [
79       rlupton20
80       edude03
81       saschagrunert
82       Frostman
83       Chili-Man
84       techknowlogick
85     ];
86   };