#!/usr/bin/env bash # Runs INSIDE the NixOS minimal installer (over serial) to lay down the golden # system onto /dev/vda from the seed media. Driven by build-golden.sh. set -euo pipefail # Fast-fail signal for the driver instead of hanging until its timeout. trap 'echo "=== NINA_INSTALL_FAIL ==="; sync; sleep 2; poweroff -f' ERR SEED_DIR="$(cd "$(dirname "$0")" && pwd)" echo "=== NINA_INSTALL_START ===" # Single BIOS-bootable ext4 root (MBR) — matches grub.device=/dev/vda. parted -s /dev/vda mklabel msdos parted -s /dev/vda mkpart primary ext4 1MiB 100% parted -s /dev/vda set 1 boot on udevadm settle || true mkfs.ext4 -F -L nixos /dev/vda1 udevadm settle || true # Mount the partition device directly — the /dev/disk/by-label symlink may not # be populated by udev yet immediately after mkfs. mount /dev/vda1 /mnt # Generate hardware-configuration.nix for this disk, then drop in our config. nixos-generate-config --root /mnt cp "$SEED_DIR/configuration.nix" /mnt/etc/nixos/configuration.nix # Bake the injected nina binary (prove-the-loop: absolute-path /root/nina). install -Dm755 "$SEED_DIR/nina" /mnt/root/nina nixos-install --no-root-passwd --root /mnt echo "=== NINA_INSTALL_DONE ===" sync poweroff