From c239eca2d989378e41401333e302a910cd47f266 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Fri, 16 May 2025 21:31:51 -0700 Subject: [PATCH 1/4] nixos/k3s: get tests working again Some of the attributes fetched throw, so tryEval them. Recurse into the attribute set to pick up all the tests. (cherry picked from commit 727809f534ff37bb5e4486084a7125b04a175373) --- nixos/tests/k3s/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/tests/k3s/default.nix b/nixos/tests/k3s/default.nix index 4ee3cb760b399..5240f029139fb 100644 --- a/nixos/tests/k3s/default.nix +++ b/nixos/tests/k3s/default.nix @@ -4,9 +4,11 @@ lib ? pkgs.lib, }: let - allK3s = lib.filterAttrs (n: _: lib.strings.hasPrefix "k3s_" n) pkgs; + allK3s = lib.filterAttrs ( + n: _: lib.strings.hasPrefix "k3s_" n && (builtins.tryEval pkgs.${n}).success + ) pkgs; in -{ +lib.recurseIntoAttrs { airgap-images = lib.mapAttrs ( _: k3s: import ./airgap-images.nix { inherit system pkgs k3s; } ) allK3s; From 83085bba1d0a3ad9033e82d7f1cd4091cedfac58 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Fri, 16 May 2025 21:29:56 -0700 Subject: [PATCH 2/4] k3s: use util-linuxMinimal The full version of util-linux has systemd, NLS, and ncurses support. k3s only uses a couple utilities from it at runtime, so use the minimal version. (cherry picked from commit 44d7b6dd7bab8ff7fc71da3ba91eb09e5d19d83f) --- pkgs/applications/networking/cluster/k3s/builder.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/networking/cluster/k3s/builder.nix b/pkgs/applications/networking/cluster/k3s/builder.nix index fdd70a653ee55..5e23e64a3cbc2 100644 --- a/pkgs/applications/networking/cluster/k3s/builder.nix +++ b/pkgs/applications/networking/cluster/k3s/builder.nix @@ -69,7 +69,7 @@ lib: sqlite, stdenv, systemd, - util-linux, + util-linuxMinimal, yq-go, zstd, }: @@ -377,7 +377,7 @@ buildGoModule rec { ipset bridge-utils ethtool - util-linux # kubelet wants 'nsenter' from util-linux: https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-705994388 + util-linuxMinimal # kubelet wants 'nsenter' and 'mount' from util-linux: https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-705994388 conntrack-tools runc bash From 3708c98785612f41bc9e989ebddcb5a68fa05ae2 Mon Sep 17 00:00:00 2001 From: Morgan Jones Date: Fri, 16 May 2025 21:40:52 -0700 Subject: [PATCH 3/4] k3s: #405952: fix mount regression Until #405952 is fixed, we can use our own util-linux to avoid breaking k3s in the release. Revert this commit when that happens. (cherry picked from commit 4cf4acae57e3be36f86d3f69b9a1e98e68793863) --- .../networking/cluster/k3s/builder.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/networking/cluster/k3s/builder.nix b/pkgs/applications/networking/cluster/k3s/builder.nix index 5e23e64a3cbc2..e31d6203bc5ff 100644 --- a/pkgs/applications/networking/cluster/k3s/builder.nix +++ b/pkgs/applications/networking/cluster/k3s/builder.nix @@ -41,6 +41,7 @@ lib: ethtool, fetchFromGitHub, fetchgit, + fetchpatch, fetchurl, fetchzip, findutils, @@ -331,6 +332,17 @@ let ldflags = versionldflags; }).overrideAttrs overrideContainerdAttrs; + + # TODO (#405952): remove this patch. We had to add it to avoid a mass rebuild + # for the 25.05 release. Once the above PR is merged, switch back to plain util-linuxMinimal. + k3sUtilLinux = util-linuxMinimal.overrideAttrs (prev: { + patches = + prev.patches or [ ] + ++ lib.singleton (fetchpatch { + url = "https://github.com/util-linux/util-linux/pull/3479.patch"; + hash = "sha256-bJqpZiPli5Pm/XpDA445Ab5jesXrlcnaO6e4V0B3rSw="; + }); + }); in buildGoModule rec { pname = "k3s"; @@ -377,7 +389,7 @@ buildGoModule rec { ipset bridge-utils ethtool - util-linuxMinimal # kubelet wants 'nsenter' and 'mount' from util-linux: https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-705994388 + k3sUtilLinux # kubelet wants 'nsenter' and 'mount' from util-linux: https://github.com/kubernetes/kubernetes/issues/26093#issuecomment-705994388 conntrack-tools runc bash From d0764b7e968c6f96e08f24aae3b087c881be75b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 20 May 2025 08:54:37 +0200 Subject: [PATCH 4/4] k3s: better util-linux patch url The commit is in master so we don't need to point to the pull request --- pkgs/applications/networking/cluster/k3s/builder.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/networking/cluster/k3s/builder.nix b/pkgs/applications/networking/cluster/k3s/builder.nix index e31d6203bc5ff..8cbb824230f01 100644 --- a/pkgs/applications/networking/cluster/k3s/builder.nix +++ b/pkgs/applications/networking/cluster/k3s/builder.nix @@ -339,7 +339,7 @@ let patches = prev.patches or [ ] ++ lib.singleton (fetchpatch { - url = "https://github.com/util-linux/util-linux/pull/3479.patch"; + url = "https://github.com/util-linux/util-linux/commit/7dbfe31a83f45d5aef2b508697e9511c569ffbc8.patch"; hash = "sha256-bJqpZiPli5Pm/XpDA445Ab5jesXrlcnaO6e4V0B3rSw="; }); });