9 hasVPrefix = ver: (builtins.elemAt (lib.stringToCharacters ver) 0) == "v";
11 if k3sVersion != null then
12 if hasVPrefix k3sVersion then throw "k3sVersion should not have a v prefix" else true
20 src = fetchFromGitHub {
23 rev = "refs/tags/v${version}";
24 hash = "sha256-z+7yeX0ea/6+4aWbA5NYW/HzvVcJiSkewOvo+oXp9bE=";
27 vendorHash = "sha256-lFmIRtkUiohva2Vtg4AqHaB5McVOWW5+SFShkNqYVZ8=";
30 nativeBuildInputs = [ installShellFiles ];
32 excludedPackages = [ "tools" "docgen" ];
35 let t = "github.com/k3d-io/k3d/v${lib.versions.major version}/version"; in
36 [ "-s" "-w" "-X ${t}.Version=v${version}" ] ++ lib.optionals k3sVersionSet [ "-X ${t}.K3sVersion=v${k3sVersion}" ];
39 # skip test that uses networking
40 substituteInPlace version/version_test.go \
41 --replace "TestGetK3sVersion" "SkipGetK3sVersion"
45 installShellCompletion --cmd k3d \
46 --bash <($out/bin/k3d completion bash) \
47 --fish <($out/bin/k3d completion fish) \
48 --zsh <($out/bin/k3d completion zsh)
51 doInstallCheck = true;
52 installCheckPhase = ''
53 runHook preInstallCheck
55 $out/bin/k3d --version | grep -e "k3d version v${version}" ${lib.optionalString k3sVersionSet "-e \"k3s version v${k3sVersion}\""}
56 runHook postInstallCheck
62 homepage = "https://github.com/k3d-io/k3d/";
63 changelog = "https://github.com/k3d-io/k3d/blob/v${version}/CHANGELOG.md";
64 description = "Helper to run k3s (Lightweight Kubernetes. 5 less than k8s) in a docker container";
67 k3s is the lightweight Kubernetes distribution by Rancher: rancher/k3s
69 k3d creates containerized k3s clusters. This means, that you can spin up a
70 multi-node k3s cluster on a single machine using docker.
72 license = licenses.mit;
73 maintainers = with maintainers; [ kuznero jlesquembre ngerstle jk ricochet ];
74 platforms = platforms.linux ++ platforms.darwin;