From 75c1cae6e159b81cf0d0468b84c100aef33d162f Mon Sep 17 00:00:00 2001 From: Robert Rose Date: Wed, 3 Sep 2025 15:25:16 +0200 Subject: [PATCH] k3s: adapt to native embed package for bundled content Updates the builder to follow the upstream replacement go-bindata with the native embed package. As this affects also the bundled Traefik chart, the Traefik deployment is now also covered in tests. --- .../networking/cluster/k3s/builder.nix | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/networking/cluster/k3s/builder.nix b/pkgs/applications/networking/cluster/k3s/builder.nix index d7f98cd7ba93..abfdec8bd290 100644 --- a/pkgs/applications/networking/cluster/k3s/builder.nix +++ b/pkgs/applications/networking/cluster/k3s/builder.nix @@ -127,8 +127,14 @@ let ]; # bundled into the k3s binary - traefikChart = fetchurl chartVersions.traefik; - traefik-crdChart = fetchurl chartVersions.traefik-crd; + traefik = { + chart = fetchurl chartVersions.traefik; + name = builtins.baseNameOf chartVersions.traefik.url; + }; + traefik-crd = { + chart = fetchurl chartVersions.traefik-crd; + name = builtins.baseNameOf chartVersions.traefik-crd.url; + }; # a shortcut that provides the images archive for the host platform. Currently only supports # aarch64 (arm64) and x86_64 (amd64), throws on other architectures. @@ -267,6 +273,18 @@ let "linux" ]; + # Set flags for sqlite dbstat + CGO_CFLAGS = "-DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_USE_ALLOCA=1"; + + # Copy manifests and static charts pre build so they get embedded during build + preBuild = '' + cp -av manifests/* ./pkg/deploy/embed/ + + mkdir -p ./pkg/static/embed/charts/ + cp -v ${traefik.chart} ./pkg/static/embed/charts/${traefik.name} + cp -v ${traefik-crd.chart} ./pkg/static/embed/charts/${traefik-crd.name} + ''; + # create the multicall symlinks for k3s postInstall = '' mv $out/bin/server $out/bin/k3s @@ -402,10 +420,6 @@ buildGoModule rec { ln -vsf ${k3sCNIPlugins}/bin/cni ./bin/cni ln -vsf ${k3sContainerd}/bin/containerd-shim-runc-v2 ./bin rsync -a --no-perms --chmod u=rwX ${k3sRoot}/etc/ ./etc/ - mkdir -p ./build/static/charts - - cp ${traefikChart} ./build/static/charts - cp ${traefik-crdChart} ./build/static/charts export ARCH=$GOARCH export DRONE_TAG="v${k3sVersion}"