From fca3189a7a681108b67882972fb97fdf8a9c5123 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Fri, 23 Jun 2023 15:23:50 -0600 Subject: k3s: Fix override --- .../networking/cluster/k3s/builder.nix | 49 +++++++++++----------- .../networking/cluster/k3s/default.nix | 11 ++--- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/pkgs/applications/networking/cluster/k3s/builder.nix b/pkgs/applications/networking/cluster/k3s/builder.nix index 0d3d127e4844..88c11fac1c8b 100644 --- a/pkgs/applications/networking/cluster/k3s/builder.nix +++ b/pkgs/applications/networking/cluster/k3s/builder.nix @@ -1,3 +1,28 @@ +lib: +{ + # 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, +}: + # builder.nix contains a "builder" expression that, given k3s version and hash # variables, creates a package for that version. # Due to variance in k3s's build process, this builder only works for k3s 1.26+ @@ -32,30 +57,6 @@ , 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 diff --git a/pkgs/applications/networking/cluster/k3s/default.nix b/pkgs/applications/networking/cluster/k3s/default.nix index d8ecd79b5cae..aec9603bb234 100644 --- a/pkgs/applications/networking/cluster/k3s/default.nix +++ b/pkgs/applications/networking/cluster/k3s/default.nix @@ -1,10 +1,11 @@ { lib, stdenv, callPackage }: let - k3s_builder = import ./builder.nix; + k3s_builder = import ./builder.nix lib; + common = opts: callPackage (k3s_builder opts); in { - k3s_1_26 = (callPackage k3s_builder { }) { + k3s_1_26 = common { k3sVersion = "1.26.4+k3s1"; k3sCommit = "8d0255af07e95b841952563253d27b0d10bd72f0"; k3sRepoSha256 = "0qlszdnlsvj3hzx2p0wl3zhaw908w8a62z6vlf2g69a3c75f55cs"; @@ -17,10 +18,10 @@ in containerdVersion = "1.6.19-k3s1"; containerdSha256 = "12dwqh77wplg30kdi73d90qni23agw2cwxjd2p5lchq86mpmmwwr"; criCtlVersion = "1.26.0-rc.0-k3s1"; - }; + } { }; # 1_27 can be built with the same builder as 1_26 - k3s_1_27 = (callPackage k3s_builder { }) (import ./1_27/versions.nix) // { + k3s_1_27 = common ((import ./1_27/versions.nix) // { updateScript = ./1_27/update-script.sh; - }; + }) { }; } -- cgit 1.4.1