bitspire/deploy/nixos/build-iso.sh
Patrick Mulligan dc5f4f8aa6 feat(deploy): add batm3 ISO build target
Add batm3 to flake.nix NixOS configs, live.nix (CDC ACM kernel modules,
MEI udev rules), and build-iso.sh. Default fiat: USD.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 03:20:46 -04:00

68 lines
2.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build a bootable NixOS Live USB ISO for testing the ATM Electron app
# on physical hardware.
#
# The build is fully pure — no local pnpm or .env manipulation needed.
# After booting, provision credentials with: bash provision-atm.sh <atm-ip>
#
# Usage: bash build-iso.sh <model>
# bash build-iso.sh douro # Bay Trail, kernel 5.15, GTQ
# bash build-iso.sh tejo # UP4000, kernel 6.6, GTQ
# bash build-iso.sh sintra # UPBoard, kernel 6.6, EUR
# bash build-iso.sh batm3 # General Bytes BATM3, EBDS validator, USD
set -euo pipefail
MODEL="${1:-}"
if [ -z "$MODEL" ]; then
echo "Usage: bash build-iso.sh <model>"
echo " douro - Bay Trail Atom, kernel 5.15, eDP panel, GTQ"
echo " tejo - UP4000/UPBoard, kernel 6.6, GTQ"
echo " sintra - UPBoard, kernel 6.6, EUR"
echo " batm3 - General Bytes BATM3, EBDS validator, USD"
exit 1
fi
case "$MODEL" in
douro|tejo|sintra|batm3) ;;
*)
echo "ERROR: Unknown model '$MODEL'. Use 'douro', 'tejo', 'sintra', or 'batm3'."
exit 1
;;
esac
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
echo "=== Building Lamassu ATM Live USB ISO (model: $MODEL) ==="
echo ""
echo "This is a pure Nix build — no local pnpm required."
echo ""
cd "$REPO_ROOT"
nix build ".#iso-${MODEL}" --show-trace
# Print results
ISO_PATH=$(ls result/iso/*.iso 2>/dev/null | head -1)
if [ -z "$ISO_PATH" ]; then
echo "ERROR: ISO not found in result/iso/"
exit 1
fi
ISO_SIZE=$(du -h "$ISO_PATH" | cut -f1)
echo ""
echo "=== ISO built successfully ($MODEL) ==="
echo "File: $ISO_PATH"
echo "Size: $ISO_SIZE"
echo ""
echo "--- Write to USB flash drive ---"
echo "sudo dd if=$ISO_PATH of=/dev/sdX bs=4M status=progress oflag=sync"
echo ""
echo "--- Test in QEMU ---"
echo "qemu-system-x86_64 -enable-kvm -m 2G \\"
echo " -drive if=pflash,format=raw,readonly=on,file=/usr/share/edk2/x64/OVMF_CODE.4m.fd \\"
echo " -cdrom $ISO_PATH -display gtk,zoom-to-fit=on -vga std \\"
echo " -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::2222-:22"
echo ""
echo "--- After booting, provision credentials ---"
echo "bash provision-atm.sh # QEMU (localhost:2222)"
echo "bash provision-atm.sh <atm-ip> 22 # Real hardware on LAN"