nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 93 lines 2.4 kB view raw
1{ 2 lib, 3 buildGoModule, 4 fetchFromGitHub, 5 installShellFiles, 6 k3sVersion ? null, 7}: 8 9let 10 hasVPrefix = ver: (builtins.elemAt (lib.stringToCharacters ver) 0) == "v"; 11 k3sVersionSet = 12 if k3sVersion != null then 13 if hasVPrefix k3sVersion then throw "k3sVersion should not have a v prefix" else true 14 else 15 false; 16in 17buildGoModule rec { 18 pname = "k3d"; 19 version = "5.8.3"; 20 21 src = fetchFromGitHub { 22 owner = "k3d-io"; 23 repo = "k3d"; 24 tag = "v${version}"; 25 hash = "sha256-UBiDDZf/UtgPGRV9WUnoC32wc64nthBpBheEYOTp6Hk="; 26 }; 27 28 vendorHash = "sha256-lFmIRtkUiohva2Vtg4AqHaB5McVOWW5+SFShkNqYVZ8="; 29 deleteVendor = true; 30 31 nativeBuildInputs = [ installShellFiles ]; 32 33 excludedPackages = [ 34 "tools" 35 "docgen" 36 ]; 37 38 ldflags = 39 let 40 t = "github.com/k3d-io/k3d/v${lib.versions.major version}/version"; 41 in 42 [ 43 "-s" 44 "-w" 45 "-X ${t}.Version=v${version}" 46 ] 47 ++ lib.optionals k3sVersionSet [ "-X ${t}.K3sVersion=v${k3sVersion}" ]; 48 49 preCheck = '' 50 # skip test that uses networking 51 substituteInPlace version/version_test.go \ 52 --replace-fail "TestGetK3sVersion" "SkipGetK3sVersion" 53 ''; 54 55 postInstall = '' 56 installShellCompletion --cmd k3d \ 57 --bash <($out/bin/k3d completion bash) \ 58 --fish <($out/bin/k3d completion fish) \ 59 --zsh <($out/bin/k3d completion zsh) 60 ''; 61 62 doInstallCheck = true; 63 installCheckPhase = '' 64 runHook preInstallCheck 65 $out/bin/k3d --help 66 $out/bin/k3d --version | grep -e "k3d version v${version}" ${lib.optionalString k3sVersionSet "-e \"k3s version v${k3sVersion}\""} 67 runHook postInstallCheck 68 ''; 69 70 env.GOWORK = "off"; 71 72 meta = { 73 homepage = "https://github.com/k3d-io/k3d/"; 74 changelog = "https://github.com/k3d-io/k3d/blob/v${version}/CHANGELOG.md"; 75 description = "Helper to run k3s (Lightweight Kubernetes. 5 less than k8s) in a docker container"; 76 mainProgram = "k3d"; 77 longDescription = '' 78 k3s is the lightweight Kubernetes distribution by Rancher: rancher/k3s 79 80 k3d creates containerized k3s clusters. This means, that you can spin up a 81 multi-node k3s cluster on a single machine using docker. 82 ''; 83 license = lib.licenses.mit; 84 maintainers = with lib.maintainers; [ 85 kuznero 86 jlesquembre 87 ngerstle 88 jk 89 ricochet 90 ]; 91 platforms = lib.platforms.linux ++ lib.platforms.darwin; 92 }; 93}