added a installer script and updated spencer config
This commit is contained in:
@@ -17,12 +17,14 @@
|
||||
time.timeZone = "America/Chicago";
|
||||
|
||||
users = {
|
||||
mutableUsers = true;
|
||||
groups.bckelley = {
|
||||
gid = 1000;
|
||||
};
|
||||
|
||||
users.bckelley = {
|
||||
isNormalUser = true;
|
||||
initialHashedPassword = "$6$JkrsLF/aMl7rdZx2$XL0hCWsUZJ3Tvb2ffK1X/Fm/g3OVhc3KUapUi1FCALs4lmJGGyJh9WO2ydF.dH.K3QAjUvKp3Bv647j/AxwBH.";
|
||||
uid = 1000;
|
||||
group = "bckelley";
|
||||
shell = pkgs.fish;
|
||||
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
# Clear screen for readability
|
||||
clear
|
||||
|
||||
echo "################################################################"
|
||||
echo "# WARNING: This script will wipe the target drive! #"
|
||||
echo "# #"
|
||||
echo "# This script is designed to be run from a NixOS Live ISO. #"
|
||||
echo "# It handles LVM, LUKS encryption, Swap, and User Passwords. #"
|
||||
echo "# It will prompt you for your specific hardware details and #"
|
||||
echo "# then automate the partitioning, formatting, and #"
|
||||
echo "# installation using your Git repository. #"
|
||||
echo "################################################################"
|
||||
echo ""
|
||||
|
||||
# Confirm to continue
|
||||
read -p "Do you want to continue with the installation? (y/N): " START_CONFIRM
|
||||
if [[ $START_CONFIRM != [yY] ]]; then
|
||||
echo "Installation aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
# --- Prompts ---
|
||||
read -p "Enter target drive (e.g., /dev/nvme0n1 or /dev/sda): " DRIVE
|
||||
read -p "Enter hostname: " HOSTNAME
|
||||
read -p "Enter username: " USER
|
||||
read -s -p "Enter a temporary password for $USER: " USER_PASS
|
||||
echo ""
|
||||
read -p "Enter Git repo URL (e.g., gitea.com/user/dotfiles): " REPO_URL
|
||||
read -p "Enable LUKS Encryption? (y/n): " USE_LUKS
|
||||
read -p "Use LVM (Logical Volume Manager)? (y/n): " USE_LVM
|
||||
read -p "Enter Swap size (e.g., 8G, or '0' for none): " SWAP_SIZE
|
||||
|
||||
# --- Summary ---
|
||||
echo ""
|
||||
echo "Summary of installation:"
|
||||
echo "- Drive: $DRIVE"
|
||||
echo "- Hostname: $HOSTNAME"
|
||||
echo "- User: $USER"
|
||||
echo "- Repo: $REPO_URL"
|
||||
echo "- LUKS: $USE_LUKS"
|
||||
echo "- LVM: $USE_LVM"
|
||||
echo "- Swap: $SWAP_SIZE"
|
||||
echo ""
|
||||
|
||||
read -p "Final confirmation: Wipe $DRIVE and install $HOSTNAME? (y/N): " FINAL_CONFIRM
|
||||
if [[ $FINAL_CONFIRM != [yY] ]] then
|
||||
echo "Installation aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "--- Preparing Disk: $DRIVE ---"
|
||||
# --- Partition Naming Logic ---
|
||||
if [[ $DRIVE == *nvme* || $DRIVE == *mmcblk* ]]; then
|
||||
BOOT_PART="${DRIVE}p1"
|
||||
DATA_PART="${DRIVE}p2"
|
||||
else
|
||||
BOOT_PART="${DRIVE}1"
|
||||
DATA_PART="${DRIVE}2"
|
||||
fi
|
||||
|
||||
# --- Disk Prep ---
|
||||
# --- Disk Prep ---
|
||||
echo "--- Wiping $DRIVE ---"
|
||||
sudo wipefs -a "$DRIVE"
|
||||
sudo parted "$DRIVE" -- mklabel gpt
|
||||
sudo parted "$DRIVE" -- mkpart ESP fat32 1MiB 512MiB
|
||||
sudo parted "$DRIVE" -- set 1 esp on
|
||||
sudo parted "$DRIVE" -- mkpart primary 512MiB 100%
|
||||
sudo udevadm settle
|
||||
|
||||
# --- Formatting Boot ---
|
||||
sudo mkfs.fat -F 32 -n boot "$BOOT_PART"
|
||||
|
||||
# --- LUKS Encryption ---
|
||||
ROOT_DEV="$DATA_PART"
|
||||
if [[ $USE_LUKS == [yY] ]]; then
|
||||
echo "--- Configuring LUKS ---"
|
||||
sudo cryptsetup luksFormat "$DATA_PART"
|
||||
sudo cryptsetup open "$DATA_PART" cryptroot
|
||||
ROOT_DEV="/dev/mapper/cryptroot"
|
||||
fi
|
||||
|
||||
# --- LVM / Partitioning Logic ---
|
||||
if [[ $USE_LVM == [yY] ]]; then
|
||||
echo "--- Configuring LVM ---"
|
||||
sudo pvcreate "$ROOT_DEV"
|
||||
sudo vgcreate vg0 "$ROOT_DEV"
|
||||
|
||||
if [[ $SWAP_SIZE != "0" ]]; then
|
||||
sudo lvcreate -L "$SWAP_SIZE" -n swap vg0
|
||||
sudo mkswap -L swap /dev/vg0/swap
|
||||
sudo swapon /dev/vg0/swap
|
||||
fi
|
||||
|
||||
sudo lvcreate -l 100%FREE -n root vg0
|
||||
sudo mkfs.ext4 -L nixos /dev/vg0/root
|
||||
sudo mount /dev/vg0/root /mnt
|
||||
else
|
||||
echo "--- Configuring Standard Partition ---"
|
||||
sudo mkfs.ext4 -L nixos "$ROOT_DEV"
|
||||
sudo mount "$ROOT_DEV" /mnt
|
||||
fi
|
||||
|
||||
echo "--- Mounting Filesystems ---"
|
||||
sudo mkdir -p /mnt/boot
|
||||
sudo mount /dev/disk/by-label/boot /mnt/boot
|
||||
|
||||
echo "--- Generating Hardware Configuration ---"
|
||||
# This ensures the T480's specific UUIDs are recorded
|
||||
sudo nixos-generate-config --root /mnt
|
||||
|
||||
echo "--- Installing NixOS from Gitea Flake ---"
|
||||
# We use --no-root-passwd so you can set it on first boot,
|
||||
# or it uses the password defined in your Nix config.
|
||||
sudo nixos-install --root /mnt --flake "git+https://${REPO_URL}#${HOSTNAME}"
|
||||
|
||||
echo "--- Seeding Dotfiles ---"
|
||||
sudo mkdir -p /mnt/home/$USER
|
||||
sudo nix-shell -p git --run "git clone https://${REPO_URL} /mnt/home/$USER/.dotfiles"
|
||||
sudo cp /mnt/etc/nixos/hardware-configuration.nix /mnt/home/$USER/.dotfiles/hosts/$HOSTNAME/hardware-configuration.nix
|
||||
sudo chown -R 1000:1000 /mnt/home/$USER
|
||||
|
||||
echo ""
|
||||
echo "################################################################"
|
||||
echo "# INSTALLATION COMPLETE! #"
|
||||
echo "# You can now type 'reboot' to start your new system. #"
|
||||
echo "################################################################"
|
||||
Reference in New Issue
Block a user