add a simple installer for nixos configs

This commit is contained in:
randomuser 2023-07-13 12:59:44 -05:00
parent af314b9066
commit f8de34054e
2 changed files with 78 additions and 0 deletions

77
nonpure/install.sh Normal file
View File

@ -0,0 +1,77 @@
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
read -p "NixOS configuration? (virtbox): " NIXOS_CONFIG
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/
yes | nixos-install -I nixos-config=/mnt/root/dot_testing/$NIXOS_CONFIG.nix --cores 0
mv /mnt/root/dot_testing /mnt/home/usr/dot_testing
if [ "$REBOOT" = "yes" ]; then
reboot
fi

View File

@ -0,0 +1 @@
# sets up a 'traditional' environment in our home directory