about summary refs log tree commit diff
path: root/pkgs/applications/networking/cluster/k3s
diff options
context:
space:
mode:
authorEuan Kemp <euank@euank.com>2023-05-20 15:49:08 +0900
committerEuan Kemp <euank@euank.com>2023-05-20 15:59:23 +0900
commit457f56813d21053aa3a58a6a6b5d6dcb3b019e6c (patch)
tree39cb53f2a1191ba3c7dabbab16241a72313e2556 /pkgs/applications/networking/cluster/k3s
parent68c1807f3c523788b5ce58879ec67ed9c43022d6 (diff)
downloadnixlib-457f56813d21053aa3a58a6a6b5d6dcb3b019e6c.tar
nixlib-457f56813d21053aa3a58a6a6b5d6dcb3b019e6c.tar.gz
nixlib-457f56813d21053aa3a58a6a6b5d6dcb3b019e6c.tar.bz2
nixlib-457f56813d21053aa3a58a6a6b5d6dcb3b019e6c.tar.lz
nixlib-457f56813d21053aa3a58a6a6b5d6dcb3b019e6c.tar.xz
nixlib-457f56813d21053aa3a58a6a6b5d6dcb3b019e6c.tar.zst
nixlib-457f56813d21053aa3a58a6a6b5d6dcb3b019e6c.zip
k3s: add "1_26" builder which can be used for 1_27 too
This is meant to make it easier to maintain multiple versions of the
package without having to copy+paste folders every time.

We can still copy+paste if the builders diverge enough to warrant it.
Diffstat (limited to 'pkgs/applications/networking/cluster/k3s')
-rw-r--r--pkgs/applications/networking/cluster/k3s/builders/1_26.nix (renamed from pkgs/applications/networking/cluster/k3s/1_26/default.nix)60
-rw-r--r--pkgs/applications/networking/cluster/k3s/default.nix23
2 files changed, 52 insertions, 31 deletions
diff --git a/pkgs/applications/networking/cluster/k3s/1_26/default.nix b/pkgs/applications/networking/cluster/k3s/builders/1_26.nix
index f7dbe7e6839e..fa34782d39a2 100644
--- a/pkgs/applications/networking/cluster/k3s/1_26/default.nix
+++ b/pkgs/applications/networking/cluster/k3s/builders/1_26.nix
@@ -1,5 +1,4 @@
-{ stdenv
-, lib
+{ lib
 , makeWrapper
 , socat
 , iptables
@@ -27,6 +26,30 @@
 , pkgsBuildBuild
 }:
 
+{
+  # git tag
+  k3sVersion,
+  # commit hash
+  k3sCommit,
+  k3sRepoSha256 ? lib.fakeHash,
+  k3sVendorSha256 ? lib.fakeHash,
+  # taken from ./scripts/version.sh VERSION_ROOT https://github.com/k3s-io/k3s/blob/v1.23.3%2Bk3s1/scripts/version.sh#L47
+  k3sRootVersion,
+  k3sRootSha256 ? lib.fakeHash,
+  # Based on the traefik charts here: https://github.com/k3s-io/k3s/blob/d71ab6317e22dd34673faa307a412a37a16767f6/scripts/download#L29-L32
+  # see also https://github.com/k3s-io/k3s/blob/d71ab6317e22dd34673faa307a412a37a16767f6/manifests/traefik.yaml#L8
+  chartVersions,
+  # taken from ./scripts/version.sh VERSION_CNIPLUGINS https://github.com/k3s-io/k3s/blob/v1.23.3%2Bk3s1/scripts/version.sh#L45
+  k3sCNIVersion,
+  k3sCNISha256 ? lib.fakeHash,
+  # taken from ./scripts/version.sh VERSION_CONTAINERD
+  containerdVersion,
+  containerdSha256 ? lib.fakeHash,
+  # run `grep github.com/kubernetes-sigs/cri-tools go.mod | head -n1 | awk '{print $4}'` in the k3s repo at the tag
+  criCtlVersion,
+  updateScript ? null,
+}:
+
 # k3s is a kinda weird derivation. One of the main points of k3s is the
 # simplicity of it being one binary that can perform several tasks.
 # However, when you have a good package manager (like nix), that doesn't
@@ -47,31 +70,6 @@
 # Those pieces of software we entirely ignore upstream's handling of, and just
 # make sure they're in the path if desired.
 let
-  k3sVersion = "1.26.4+k3s1";     # k3s git tag
-  k3sCommit = "8d0255af07e95b841952563253d27b0d10bd72f0"; # k3s git commit at the above version
-  k3sRepoSha256 = "0qlszdnlsvj3hzx2p0wl3zhaw908w8a62z6vlf2g69a3c75f55cs";
-  k3sVendorSha256 = "sha256-JXTsZYtTspu/pWMRSS2BcegktawBJ6BK7YEKbz1J/ao=";
-
-  # nix generated by update.sh
-  # Based on the traefik charts here: https://github.com/k3s-io/k3s/blob/d71ab6317e22dd34673faa307a412a37a16767f6/scripts/download#L29-L32
-  # see also https://github.com/k3s-io/k3s/blob/d71ab6317e22dd34673faa307a412a37a16767f6/manifests/traefik.yaml#L8
-  # At the time of writing, there are two traefik charts, and that's it
-  charts = import ./chart-versions.nix;
-
-  # taken from ./scripts/version.sh VERSION_ROOT https://github.com/k3s-io/k3s/blob/v1.23.3%2Bk3s1/scripts/version.sh#L47
-  k3sRootVersion = "0.12.1";
-  k3sRootSha256 = "0724yx3zk89m2239fmdgwzf9w672pik71xqrvgb7pdmknmmdn9f4";
-
-  # taken from ./scripts/version.sh VERSION_CNIPLUGINS https://github.com/k3s-io/k3s/blob/v1.23.3%2Bk3s1/scripts/version.sh#L45
-  k3sCNIVersion = "1.1.1-k3s1";
-  k3sCNISha256 = "14mb3zsqibj1sn338gjmsyksbm0mxv9p016dij7zidccx2rzn6nl";
-
-  # taken from ./scripts/version.sh VERSION_CONTAINERD
-  containerdVersion = "1.6.19-k3s1";
-  containerdSha256 = "12dwqh77wplg30kdi73d90qni23agw2cwxjd2p5lchq86mpmmwwr";
-
-  # run `grep github.com/kubernetes-sigs/cri-tools go.mod | head -n1 | awk '{print $4}'` in the k3s repo at the tag
-  criCtlVersion = "1.26.0-rc.0-k3s1";
 
   baseMeta = with lib; {
     description = "A lightweight Kubernetes distribution";
@@ -99,8 +97,8 @@ let
   ];
 
   # bundled into the k3s binary
-  traefikChart = fetchurl charts.traefik;
-  traefik-crdChart = fetchurl charts.traefik-crd;
+  traefikChart = fetchurl chartVersions.traefik;
+  traefik-crdChart = fetchurl chartVersions.traefik-crd;
 
   # so, k3s is a complicated thing to package
   # This derivation attempts to avoid including any random binaries from the
@@ -168,7 +166,7 @@ let
   # derivation when we've built all the binaries, but haven't bundled them in
   # with generated bindata yet.
 
-  k3sServer = buildGoModule rec {
+  k3sServer = buildGoModule {
     pname = "k3s-server";
     version = k3sVersion;
 
@@ -322,7 +320,7 @@ buildGoModule rec {
     $out/bin/k3s --version | grep -F "v${k3sVersion}" >/dev/null
   '';
 
-  passthru.updateScript = ./update.sh;
+  passthru.updateScript = updateScript;
 
   passthru.mkTests = version:
     let k3s_version = "k3s_" + lib.replaceStrings ["."] ["_"] (lib.versions.majorMinor version);
diff --git a/pkgs/applications/networking/cluster/k3s/default.nix b/pkgs/applications/networking/cluster/k3s/default.nix
new file mode 100644
index 000000000000..52beacf7e6c1
--- /dev/null
+++ b/pkgs/applications/networking/cluster/k3s/default.nix
@@ -0,0 +1,23 @@
+{ lib, stdenv, callPackage }:
+
+let
+  # The 1_26 builder can compile 1.26, and hopefully newer versions
+  k3s_1_26_builder = import ./builders/1_26.nix;
+in
+{
+  k3s_1_26 = (callPackage k3s_1_26_builder { }) {
+    k3sVersion = "1.26.4+k3s1";
+    k3sCommit = "8d0255af07e95b841952563253d27b0d10bd72f0";
+    k3sRepoSha256 = "0qlszdnlsvj3hzx2p0wl3zhaw908w8a62z6vlf2g69a3c75f55cs";
+    k3sVendorSha256 = "sha256-JXTsZYtTspu/pWMRSS2BcegktawBJ6BK7YEKbz1J/ao=";
+    chartVersions = import ./1_26/chart-versions.nix;
+    k3sRootVersion = "0.12.1";
+    k3sRootSha256 = "0724yx3zk89m2239fmdgwzf9w672pik71xqrvgb7pdmknmmdn9f4";
+    k3sCNIVersion = "1.1.1-k3s1";
+    k3sCNISha256 = "14mb3zsqibj1sn338gjmsyksbm0mxv9p016dij7zidccx2rzn6nl";
+    containerdVersion = "1.6.19-k3s1";
+    containerdSha256 = "12dwqh77wplg30kdi73d90qni23agw2cwxjd2p5lchq86mpmmwwr";
+    criCtlVersion = "1.26.0-rc.0-k3s1";
+    updateScript = ./1_26/update-script.sh;
+  };
+}