Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 87 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 buildGoModule, 5 fetchFromGitHub, 6 installShellFiles, 7 testers, 8}: 9 10buildGoModule (finalAttrs: { 11 pname = "kubernetes-helm"; 12 version = "3.18.4"; 13 14 src = fetchFromGitHub { 15 owner = "helm"; 16 repo = "helm"; 17 rev = "v${finalAttrs.version}"; 18 sha256 = "sha256-2xOrTguenFzX7rvwm1ojSqV6ARCUSPUs07y3ut9Teec="; 19 }; 20 vendorHash = "sha256-Z3OAbuoeAtChd9Sk4bbzgwIxmFrw+/1c4zyxpNP0xXg="; 21 22 subPackages = [ "cmd/helm" ]; 23 ldflags = [ 24 "-w" 25 "-s" 26 "-X helm.sh/helm/v3/internal/version.version=v${finalAttrs.version}" 27 "-X helm.sh/helm/v3/internal/version.gitCommit=${finalAttrs.src.rev}" 28 ]; 29 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 ''; 41 42 __darwinAllowLocalNetworking = true; 43 44 preCheck = '' 45 # restore ldflags for tests 46 ldflags="''${old_ldflags}" 47 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 ''; 58 59 nativeBuildInputs = [ installShellFiles ]; 60 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 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 ''; 66 67 passthru.tests.version = testers.testVersion { 68 package = finalAttrs.finalPackage; 69 command = "helm version"; 70 version = "v${finalAttrs.version}"; 71 }; 72 73 meta = with lib; { 74 homepage = "https://github.com/helm/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 }; 87})