Skip to content

Commit 50f4016

Browse files
committed
Use amazon image format for AMI import
1 parent b29ff60 commit 50f4016

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The Zen of ~~Python~~ Clawdbot, ~~by~~ shamelessly stolen from Tim Peters:
3838

3939
Deploy flow (automation-first):
4040
- Use `devenv.nix` for tooling (nixos-generators, awscli2).
41-
- Build a bootstrap NixOS image with nixos-generators (raw-efi) and upload it to S3.
41+
- Build a bootstrap NixOS image with nixos-generators (amazon) and upload it to S3.
4242
- Use `nix/hosts/clawdinator-1-image.nix` for image builds.
4343
- CI is preferred: `.github/workflows/image-build.yml` runs build → S3 upload → AMI import.
4444
- Bootstrap S3 bucket + scoped IAM user + VM Import role with `infra/opentofu/aws` (use homelab-admin creds).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Deploy (automation‑first):
4646

4747
Image-based deploy (Option A, recommended):
4848
1) Build a bootstrap image with nixos-generators:
49-
- `nix run github:nix-community/nixos-generators -- -f raw-efi -c nix/hosts/clawdinator-1-image.nix -o dist`
49+
- `nix run github:nix-community/nixos-generators -- -f amazon -c nix/hosts/clawdinator-1-image.nix -o dist`
5050
2) Upload the raw image to S3 (private object).
5151
3) Import into AWS as an AMI (`aws ec2 import-image`).
5252
4) Launch hosts from the AMI.

docs/POC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Secrets wiring:
1818
- Infra: AWS credentials for OpenTofu and CI.
1919

2020
Image pipeline:
21-
- Build a bootstrap image with nixos-generators (raw-efi) from `nix/hosts/clawdinator-1-image.nix`, upload to S3, import as an AMI via `aws ec2 import-image`.
21+
- Build a bootstrap image with nixos-generators (amazon) from `nix/hosts/clawdinator-1-image.nix`, upload to S3, import as an AMI via `aws ec2 import-image`.
2222
- Launch instances from the AMI, then nixos-rebuild applies full config.
2323
- Runtime: explicit token files via agenix (standard).
2424
- GitHub token is required. Prefer GitHub App (`services.clawdinator.githubApp.*`) to mint short-lived tokens.

scripts/build-image.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ set -euo pipefail
33

44
config_path="${CONFIG_PATH:-nix/hosts/clawdinator-1-image.nix}"
55
out_dir="${OUT_DIR:-dist}"
6+
format="${IMAGE_FORMAT:-amazon}"
67

78
if [ -e "${out_dir}" ]; then
89
rm -rf "${out_dir}"
910
fi
1011

11-
nix run github:nix-community/nixos-generators -- -f raw-efi -c "${config_path}" -o "${out_dir}"
12+
nix run github:nix-community/nixos-generators -- -f "${format}" -c "${config_path}" -o "${out_dir}"
1213

13-
if [ ! -f "${out_dir}/nixos.img" ]; then
14-
echo "Expected image at ${out_dir}/nixos.img" >&2
14+
image_file="$(find "${out_dir}" -maxdepth 2 -type f \( -name "*.img" -o -name "*.vhd" -o -name "*.vhdx" -o -name "*.raw" \) | head -n 1)"
15+
if [ -z "${image_file}" ]; then
16+
echo "No image found in ${out_dir} for format ${format}" >&2
1517
exit 1
1618
fi
19+
20+
cp -f "${image_file}" "${out_dir}/nixos.img"

scripts/import-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bucket="${S3_BUCKET:?S3_BUCKET required}"
55
key="${S3_KEY:?S3_KEY required}"
66
region="${AWS_REGION:?AWS_REGION required}"
77

8-
boot_mode="${AMI_BOOT_MODE:-uefi}"
8+
boot_mode="legacy-bios"
99
arch="${AMI_ARCH:-x86_64}"
1010

1111
timestamp="$(date -u +%Y%m%d%H%M%S)"

0 commit comments

Comments
 (0)