summaryrefslogtreecommitdiff
path: root/scripts/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/install.sh')
-rw-r--r--scripts/install.sh88
1 files changed, 0 insertions, 88 deletions
diff --git a/scripts/install.sh b/scripts/install.sh
deleted file mode 100644
index 8a8c3d7..0000000
--- a/scripts/install.sh
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-# --- Defaults ---
-HOSTNAME=""
-DISKS=()
-KEY_LOCATION="./private.asc"
-REPO_URL="https://codeberg.org/adikro/nixos-config.git"
-TEMP_CONFIG="/tmp/config/etc/nixos"
-USE_FACTER=true
-WRITE_EFI=true
-
-# --- Parse Arguments ---
-PARSED_ARGS=$(getopt -o h:d:r:k:gn --long hostname:,disk:,repo:,key:,generate-config,no-efi -- "$@")
-eval set -- "$PARSED_ARGS"
-
-while true; do
- case "$1" in
- -h|--hostname) HOSTNAME="$2"; shift 2 ;;
- -d|--disk) DISKS+=("$2"); shift 2 ;;
- -r|--repo) REPO_URL="$2"; shift 2 ;;
- -k|--key) KEY_LOCATION="$2"; shift 2 ;;
- -g|--generate-config) USE_FACTER=false; shift ;;
- -n|--no-efi) WRITE_EFI=false; shift ;;
- --) shift; break ;;
- *) echo "Internal error!"; exit 1 ;;
- esac
-done
-
-# --- Validation ---
-if [[ -z "$HOSTNAME" || ${#DISKS[@]} -eq 0 ]]; then
- echo "Usage: sudo nix run .#install -- -h <name> -d main:/dev/nvme0n1 [-d storage:/dev/sda]"
- exit 1
-fi
-
-if [[ ! -f "$KEY_LOCATION" ]]; then
- echo "Error: Private key not found at $KEY_LOCATION. Cannot proceed without GPG."
- exit 1
-fi
-
-# --- Summary & Confirmation ---
-echo "------------------------------------------------------------"
-echo "INSTALLATION PLAN"
-echo " Hostname: $HOSTNAME"
-echo " Target Disks:"
-for disk in "${DISKS[@]}"; do echo " - $disk"; done
-echo "------------------------------------------------------------"
-read -p "Warning: This will format the disks listed above. Proceed? (y/N): " confirm
-[[ "$confirm" != [yY] ]] && exit 1
-
-echo "### 1. Importing GPG Key ###"
-export GPG_TTY=$(tty)
-gpg --import "$KEY_LOCATION"
-
-echo "### 2. Cloning Configuration ###"
-sudo rm -rf "$TEMP_CONFIG"
-git clone "$REPO_URL" "$TEMP_CONFIG"
-cd "$TEMP_CONFIG"
-
-echo "### 3. Hardware Configuration ###"
-HOST_DIR="./hosts/$HOSTNAME"
-mkdir -p "$HOST_DIR"
-
-if [ "$USE_FACTER" = true ]; then
- nixos-facter -o "$HOST_DIR/facter.json"
- git add "$HOST_DIR/facter.json"
-else
- sudo nixos-generate-config --no-filesystems --root /tmp/nixos-gen-root
- mv /tmp/nixos-gen-root/etc/nixos/hardware-configuration.nix "$HOST_DIR/hardware-configuration.nix"
- git add "$HOST_DIR/hardware-configuration.nix"
-fi
-
-echo "### 4. SOPS Key Extraction ###"
-if printf '%s\n' "${DISKS[@]}" | rg -qv "^main:"; then
- sops -d --extract '["crypt_key"]' secrets/secrets.yaml > /tmp/crypt.key
-fi
-
-echo "### 5. Disko Install ###"
-DISKO_ARGS=(--flake ".#$HOSTNAME")
-for pair in "${DISKS[@]}"; do
- IFS=":" read -r D_NAME D_DEV <<< "$pair"
- DISKO_ARGS+=(--disk "$D_NAME" "$D_DEV")
-done
-[[ "$WRITE_EFI" == true ]] && DISKO_ARGS+=(--write-efi-boot-entries)
-
-sudo disko-install "${DISKO_ARGS[@]}"
-
-echo "INSTALL COMPLETE. Reboot and run setup script."