Files
nixos-dev-vm/install.sh
T

51 lines
2.8 KiB
Bash

#!/usr/bin/env bash
# NixOS Dev VM — one-shot install for Proxmox + SeaBIOS (BIOS/MBR)
# Run from the NixOS minimal ISO live shell as root.
set -euo pipefail
DISK=/dev/sda
GITEA="https://gitea.klhoud.com/konrad/nixos-dev-vm/raw/branch/main"
echo "╔══════════════════════════════════════════╗"
echo "║ NixOS Dev VM Install — klhoud.com ║"
echo "╚══════════════════════════════════════════╝"
echo
# ── 1. Partition (MBR/BIOS) ────────────────────────────────────────────────
echo "[1/5] Partitioning ${DISK}..."
parted "${DISK}" -- mklabel msdos
parted "${DISK}" -- mkpart primary ext4 1MiB -4GiB
parted "${DISK}" -- mkpart primary linux-swap -4GiB 100%
parted "${DISK}" -- set 1 boot on
# ── 2. Format ──────────────────────────────────────────────────────────────
echo "[2/5] Formatting..."
mkfs.ext4 -L nixos "${DISK}1"
mkswap -L swap "${DISK}2"
# ── 3. Mount ───────────────────────────────────────────────────────────────
echo "[3/5] Mounting..."
mount /dev/disk/by-label/nixos /mnt
swapon "${DISK}2"
# ── 4. Place config ────────────────────────────────────────────────────────
echo "[4/5] Fetching config from Gitea..."
nixos-generate-config --root /mnt
curl -fsSL "${GITEA}/configuration.nix" -o /mnt/etc/nixos/configuration.nix
curl -fsSL "${GITEA}/flake.nix" -o /mnt/etc/nixos/flake.nix
curl -fsSL "${GITEA}/home.nix" -o /mnt/etc/nixos/home.nix
# Keep the generated hardware-configuration.nix
# ── 5. Install ─────────────────────────────────────────────────────────────
echo "[5/5] Installing NixOS (this takes a while)..."
nixos-install --flake /mnt/etc/nixos#nixos-dev --no-root-passwd
echo
echo "╔══════════════════════════════════════════╗"
echo "║ Done! ✓ ║"
echo "╚══════════════════════════════════════════╝"
echo "Reboot with: reboot"
echo "Then SSH: ssh konrad@<VM-IP>"
ip addr show | grep "inet " | grep -v 127 || true