This reduces the filtering and renaming of airgap images archives to make the update script and builder more resilient to upstream changes. Additionally, it reduces the code of the k3s builder.
···5960- `ansible-later` has been removed because it was discontinued by the author.
61000000062- `stalwart-mail` since `0.13.0` "introduces a significant redesign of the MTA’s delivery and queueing subsystem". See [the upgrading announcement for the `0.13.0` release](https://github.com/stalwartlabs/stalwart/blob/89b561b5ca1c5a11f2a768b4a2cfef0f473b7a01/UPGRADING.md#upgrading-from-v012x-and-v011x-to-v013x).
6364- Greetd and its original greeters (`tuigreet`, `gtkgreet`, `qtgreet`, `regreet`, `wlgreet`) were moved from `greetd` namespace to top level (`greetd.tuigreet` -> `tuigreet`, `greetd.greetd` -> `greetd`, etc). The original attrs are available for compatibility as passthrus of `greetd`, but will emit a warning. They will be removed in future releases.
···5960- `ansible-later` has been removed because it was discontinued by the author.
6162+- `k3s` airgap images passthru attributes have changed:
63+ - `imagesList` was removed
64+ - `airgapImages` was renamed to `airgap-images`
65+ - `airgapImagesAmd64` was renamed to `airgap-images-amd64-tar-zst`
66+ - `airgapImagesArm64` was renamed to `airgap-images-arm64-tar-zst`
67+ - `airgapImagesArm` was renamed to `airgap-images-arm-tar-zst`
68+69- `stalwart-mail` since `0.13.0` "introduces a significant redesign of the MTA’s delivery and queueing subsystem". See [the upgrading announcement for the `0.13.0` release](https://github.com/stalwartlabs/stalwart/blob/89b561b5ca1c5a11f2a768b4a2cfef0f473b7a01/UPGRADING.md#upgrading-from-v012x-and-v011x-to-v013x).
7071- Greetd and its original greeters (`tuigreet`, `gtkgreet`, `qtgreet`, `regreet`, `wlgreet`) were moved from `greetd` namespace to top level (`greetd.tuigreet` -> `tuigreet`, `greetd.greetd` -> `greetd`, etc). The original attrs are available for compatibility as passthrus of `greetd`, but will emit a warning. They will be removed in future releases.
+1-9
nixos/tests/k3s/airgap-images.nix
···22 "--disable servicelb"
23 "--disable traefik"
24 ];
25- images = [ k3s.airgapImages ];
26 };
27 };
2829 testScript = ''
30- import json
31-32- start_all()
33 machine.wait_for_unit("k3s")
34 machine.wait_until_succeeds("journalctl -r --no-pager -u k3s | grep \"Imported images from /var/lib/rancher/k3s/agent/images/\"")
35- images = json.loads(machine.succeed("crictl img -o json"))
36- image_names = [i["repoTags"][0] for i in images["images"]]
37- with open("${k3s.imagesList}") as expected_images:
38- for line in expected_images:
39- assert line.rstrip() in image_names, f"The image {line.rstrip()} is not present in the airgap images archive"
40 '';
41 }
42)
···130 traefikChart = fetchurl chartVersions.traefik;
131 traefik-crdChart = fetchurl chartVersions.traefik-crd;
132133- mutFirstChar =
134- f: s:
135- let
136- firstChar = f (lib.substring 0 1 s);
137- rest = lib.substring 1 (-1) s;
138- in
139- firstChar + rest;
140-141- kebabToCamel =
142- s:
143- mutFirstChar lib.toLower (lib.concatMapStrings (mutFirstChar lib.toUpper) (lib.splitString "-" s));
144-145- # finds the images archive for the desired architecture, throws in case no suitable archive is found
146- findImagesArchive =
147- arch:
148- let
149- imagesVersionsNames = builtins.attrNames imagesVersions;
150- in
151- lib.findFirst (
152- n: lib.hasInfix arch n
153- ) (throw "k3s: no airgap images for ${arch} available") imagesVersionsNames;
154-155 # a shortcut that provides the images archive for the host platform. Currently only supports
156 # aarch64 (arm64) and x86_64 (amd64), throws on other architectures.
157- airgapImages = fetchurl (
158- if stdenv.hostPlatform.isAarch64 then
159- imagesVersions.${findImagesArchive "arm64"}
160- else if stdenv.hostPlatform.isx86_64 then
161- imagesVersions.${findImagesArchive "amd64"}
162- else
163- throw "k3s: airgap images cannot be found automatically for architecture ${stdenv.hostPlatform.linuxArch}, consider using an image archive with an explicit architecture."
164- );
165166 # so, k3s is a complicated thing to package
167 # This derivation attempts to avoid including any random binaries from the
···467 '';
468469 passthru = {
470- inherit airgapImages;
471 k3sCNIPlugins = k3sCNIPlugins;
472 k3sContainerd = k3sContainerd;
473 k3sRepo = k3sRepo;
···481 lib.mapAttrs (name: value: nixosTests.k3s.${name}.${k3s_version}) nixosTests.k3s;
482 tests = passthru.mkTests k3sVersion;
483 updateScript = updateScript;
00000484 }
485- // (lib.mapAttrs' (
486- name: _: lib.nameValuePair (kebabToCamel name) (fetchurl imagesVersions.${name})
487- ) imagesVersions);
488489 meta = baseMeta;
490}
···130 traefikChart = fetchurl chartVersions.traefik;
131 traefik-crdChart = fetchurl chartVersions.traefik-crd;
1320000000000000000000000133 # a shortcut that provides the images archive for the host platform. Currently only supports
134 # aarch64 (arm64) and x86_64 (amd64), throws on other architectures.
135+ airgap-images =
136+ {
137+ x86_64-linux = fetchurl imagesVersions.airgap-images-amd64-tar-zst;
138+ aarch64-linux = fetchurl imagesVersions.airgap-images-arm64-tar-zst;
139+ }
140+ .${stdenv.hostPlatform.system}
141+ or (throw "k3s: no airgap images available for system ${stdenv.hostPlatform.system}, consider using an image archive with an explicit architecture.");
0142143 # so, k3s is a complicated thing to package
144 # This derivation attempts to avoid including any random binaries from the
···444 '';
445446 passthru = {
447+ inherit airgap-images;
448 k3sCNIPlugins = k3sCNIPlugins;
449 k3sContainerd = k3sContainerd;
450 k3sRepo = k3sRepo;
···458 lib.mapAttrs (name: value: nixosTests.k3s.${name}.${k3s_version}) nixosTests.k3s;
459 tests = passthru.mkTests k3sVersion;
460 updateScript = updateScript;
461+ imagesList = throw "k3s.imagesList was removed";
462+ airgapImages = throw "k3s.airgapImages was renamed to k3s.airgap-images";
463+ airgapImagesAmd64 = throw "k3s.airgapImagesAmd64 was renamed to k3s.airgap-images-amd64-tar-zst";
464+ airgapImagesArm64 = throw "k3s.airgapImagesArm64 was renamed to k3s.airgap-images-arm64-tar-zst";
465+ airgapImagesArm = throw "k3s.airgapImagesArm was renamed to k3s.airgap-images-arm-tar-zst";
466 }
467+ // (lib.mapAttrs (_: value: fetchurl value) imagesVersions);
00468469 meta = baseMeta;
470}
···83SHA256_HASHES="\
84$($CURL "https://github.com/k3s-io/k3s/releases/download/v${K3S_VERSION}/sha256sum-amd64.txt")
85$($CURL "https://github.com/k3s-io/k3s/releases/download/v${K3S_VERSION}/sha256sum-arm64.txt")
86-$($CURL "https://github.com/k3s-io/k3s/releases/download/v${K3S_VERSION}/sha256sum-arm.txt")
87-$($CURL "https://github.com/k3s-io/k3s/releases/download/v${K3S_VERSION}/k3s-images.txt" | sha256sum | cut -d' ' -f1) k3s-images.txt"
8889# Get all airgap images files associated with this release
90IMAGES_ARCHIVES=$($CURL "https://api.github.com/repos/k3s-io/k3s/releases/tags/v${K3S_VERSION}" | \
91- # Filter the assets so that only zstd archives and text files that have "images" in their name remain
92- jq -r '.assets[] | select(.name | (contains("images") and (endswith(".tar.zst") or endswith("k3s-images.txt")))) |
93- "\(.name) \(.browser_download_url)"')
9495# Create a JSON object for each airgap images file and prefetch all download URLs in the process
96# Combine all JSON objects and write the result to images-versions.json
97while read -r name url; do
98 # Pick the right hash based on the name
99 sha256=$(grep "$name" <<< "$SHA256_HASHES" | cut -d ' ' -f 1)
100- # Remove the k3s- prefix and file endings
101- clean_name=$(sed -e 's/^k3s-//' -e 's/\.tar\.zst//' -e 's/\.txt/-list/' <<< "$name")
102 jq --null-input --arg name "$clean_name" \
103 --arg url "$url" \
104 --arg sha256 "$sha256" \
···83SHA256_HASHES="\
84$($CURL "https://github.com/k3s-io/k3s/releases/download/v${K3S_VERSION}/sha256sum-amd64.txt")
85$($CURL "https://github.com/k3s-io/k3s/releases/download/v${K3S_VERSION}/sha256sum-arm64.txt")
86+$($CURL "https://github.com/k3s-io/k3s/releases/download/v${K3S_VERSION}/sha256sum-arm.txt")"
08788# Get all airgap images files associated with this release
89IMAGES_ARCHIVES=$($CURL "https://api.github.com/repos/k3s-io/k3s/releases/tags/v${K3S_VERSION}" | \
90+ # Filter the assets for airgap images archives
91+ jq -r '.assets[] | select(.name | test("^k3s-airgap-images-.*\\.tar\\.")) | "\(.name) \(.browser_download_url)"')
09293# Create a JSON object for each airgap images file and prefetch all download URLs in the process
94# Combine all JSON objects and write the result to images-versions.json
95while read -r name url; do
96 # Pick the right hash based on the name
97 sha256=$(grep "$name" <<< "$SHA256_HASHES" | cut -d ' ' -f 1)
98+ # Remove the k3s prefix and replace all dots with hyphens
99+ clean_name=$(sed -e "s/^k3s-//" -e "s/\./-/g" <<< "$name")
100 jq --null-input --arg name "$clean_name" \
101 --arg url "$url" \
102 --arg sha256 "$sha256" \