dot_testing/nonpure/install.sh

80 lines
1.1 KiB
Bash
Raw Normal View History

if [ "$(id -u)" -eq 1000 ]; then
printf "switch to the root user, and try again.\n"
exit 1
fi
lsblk
read -p "Drive name? (/dev/vda): " DRIVE
2023-10-15 13:33:13 -05:00
ls ../boxes
read -p "NixOS configuration? (virtbox): " NIXOS_CONFIG
2023-10-15 13:33:13 -05:00
read -p "Reboot? (yes/no, default 'yes'): " REBOOT
umount -f /mnt/boot
umount -f /mnt
swapoff -a
nix-env -iA nixos.git
if [ -z "$DRIVE" ]; then
DRIVE="/dev/vda"
fi
if [ -z "$NIXOS_CONFIG" ]; then
NIXOS_CONFIG="virtbox"
fi
if [ -z "$REBOOT" ]; then
REBOOT="yes"
fi
fdisk "$DRIVE" <<EOF
d
d
d
d
n
p
1
+200M
y
n
p
2
+8G
y
n
p
3
y
w
EOF
yes | mkfs.ext4 "$DRIVE"1
yes | mkswap "$DRIVE"2
yes | mkfs.ext4 "$DRIVE"3
mount "$DRIVE"3 /mnt
mkdir /mnt/boot
mount "$DRIVE"1 /mnt/boot
swapon "$DRIVE"2
nixos-generate-config --root /mnt
git clone https://git.beepboop.systems/rndusr/dot_testing /mnt/root/dot_testing
cp /mnt/etc/nixos/hardware-configuration.nix /mnt/root/dot_testing/
2023-10-15 13:33:13 -05:00
yes | nixos-install -I nixos-config=/mnt/root/dot_testing/boxes/$NIXOS_CONFIG.nix --cores 0
mv /mnt/root/dot_testing /mnt/home/usr/dot_testing
if [ "$REBOOT" = "yes" ]; then
reboot
fi