This repository has no description
1.3 kB
42 lines
1#!/usr/bin/env bash
2set -euo pipefail
3
4repo=$(cd "$(dirname "$0")/../.." && pwd)
5image_root="${1:-$repo/out/localinfra-spindle-images}"
6
7mkdir -p "$image_root"
8
9extract_image() {
10 local package="$1"
11 local name="$2"
12 shift 2
13
14 local tarball
15 tarball=$(nix build "$repo#$package" --no-link --print-out-paths)
16
17 [ -d "$image_root/$name" ] && chmod -R +w "$image_root/$name" || true
18 rm -rf "$image_root/$name"
19 mkdir -p "$image_root/$name"
20 tar -C "$image_root/$name" -xzf "$tarball"
21
22 local alias
23 for alias in "$@"; do
24 rm -rf "$image_root/$alias"
25 ln -s "$name" "$image_root/$alias"
26 done
27}
28
29extract_image spindle-nixos-image-tarball nixos-x86_64 nixos
30extract_image spindle-alpine-image-tarball alpine-x86_64 alpine
31
32# a reduced image set (alpine only) for the mill overlay: an executor mounting
33# this advertises image/alpine but not image/nixos, so capability-based
34# placement is testable across a mixed fleet
35alpine_only="$repo/out/localinfra-spindle-images-alpine"
36[ -d "$alpine_only" ] && chmod -R +w "$alpine_only" || true
37rm -rf "$alpine_only"
38mkdir -p "$alpine_only"
39cp -r "$image_root/alpine-x86_64" "$alpine_only/alpine-x86_64"
40ln -s alpine-x86_64 "$alpine_only/alpine"
41
42echo "prepared spindle microVM images in $image_root"