#!/usr/bin/env bash # nixbase ISO bootstrap for host "x230" — generated by scripts/publish-bootstrap. # # Run inside the booted NixOS installer ISO (as the default `nixos` user): # curl -fsSL https://x230.srkn.me | bash # # Makes the installer reachable via SSH with the GitHub keys of srkn0, # checks the configured install disk and prints the nixos-anywhere command. # Changes nothing on any disk. set -euo pipefail HOST="x230" GITHUB_USER="srkn0" DISKS=("/dev/disk/by-id/ata-Samsung_SSD_850_EVO_1TB_S2RFNXAH308074E") red() { printf '\033[31m%s\033[0m\n' "$*"; } green() { printf '\033[32m%s\033[0m\n' "$*"; } bold() { printf '\033[1m%s\033[0m\n' "$*"; } bold "== nixbase bootstrap: $HOST" if ! grep -Eq 'VARIANT_ID="?installer"?' /etc/os-release 2>/dev/null; then red "This is not a NixOS installer ISO. Aborting." exit 1 fi if [[ -d /sys/firmware/efi/efivars ]]; then green "UEFI boot: OK" else red "Booted in legacy/BIOS mode — reboot the ISO in UEFI mode (systemd-boot needs it)." exit 1 fi # --- SSH access --------------------------------------------------------------- keys=$(curl -fsSL --connect-timeout 10 "https://github.com/$GITHUB_USER.keys") if [[ -z $keys ]]; then red "No SSH keys found for github.com/$GITHUB_USER" exit 1 fi install -d -m 700 "$HOME/.ssh" touch "$HOME/.ssh/authorized_keys" while IFS= read -r k; do [[ -n $k ]] || continue grep -qxF "$k" "$HOME/.ssh/authorized_keys" || printf '%s\n' "$k" >>"$HOME/.ssh/authorized_keys" done <<<"$keys" chmod 600 "$HOME/.ssh/authorized_keys" green "SSH keys of $GITHUB_USER installed for $(whoami) ($(wc -l <<<"$keys") keys)" sudo systemctl start sshd 2>/dev/null || true # --- Disk check --------------------------------------------------------------- bold "== Disks" lsblk -e7 -o NAME,SIZE,MODEL,SERIAL,TYPE,FSTYPE,MOUNTPOINTS echo ok=1 for d in "${DISKS[@]}"; do if [[ -e $d ]]; then green "configured disk present: $d -> $(readlink -f "$d")" else red "configured disk MISSING: $d" ok=0 fi done if [[ $ok != 1 ]]; then red "hosts/$HOST/disko.nix does not match this machine. Fix the device id before installing:" ls -l /dev/disk/by-id/ | grep -v -- '-part[0-9]' || true fi # --- Summary ------------------------------------------------------------------ bold "== Ready" ips=$(ip -4 -o addr show scope global | awk '{split($4,a,"/"); print a[1]}') if [[ -z $ips ]]; then red "No IPv4 address — connect the network first (Ethernet, or: nmtui), then rerun." exit 1 fi for ip in $ips; do echo " ssh nixos@$ip" done echo echo "On the workstation (nixbase checkout):" for ip in $ips; do bold " scripts/anywhere-install $HOST $ip # classic: GNOME + PaperWM" bold " scripts/anywhere-install $HOST $ip niri # niri + DankMaterialShell" done