nix-setup/install.sh

44 lines
982 B
Bash
Raw Normal View History

2024-10-21 17:40:52 +02:00
#!/bin/sh
echo "this is meant to be run from the iso!!!"
if [ $(whoami) = nixos ] ; then
echo "iso detected. continue!"
else
echo "you don't appear to be in the install iso."
echo -n "are you SURE??? (y/N) "
read sure
if ! [ "$sure" = "y" ] ; then
echo "ok. exiting."
exit 0
fi
echo "i will continue."
fi
lsblk
echo -n "> what drive to install on? /dev/"
read drive
2024-10-21 17:46:02 +02:00
sudo fdisk "/dev/$drive" << "EOF"
2024-10-21 17:40:52 +02:00
o
n
p
1
a
w
EOF > /dev/null || exit 1
echo "> created DOS partition table on $disk with one bootable partition."
2024-10-21 17:46:02 +02:00
sudo mkfs.ext4 $disk*1 || exit 1 # /dev/sda 1 or /dev/nvme0n1 p1 => *1 instead of just 1
2024-10-21 17:40:52 +02:00
echo "> formatted."
2024-10-21 17:46:02 +02:00
sudo mount $disk*1 /mnt || exit 1
2024-10-21 17:40:52 +02:00
echo "> mounted."
cd /mnt/etc/nixos
echo "> installing git"
nix-env -i git > /dev/null || exit 1
echo "> downloading tudbut/nix-setup"
2024-10-21 17:46:02 +02:00
sudo git clone https://git.tudbut.de/tudbut/nix-setup
sudo rm configuration.nix
pushd nix-setup ; sudo mv $(ls -a) .. ; popd
2024-10-21 17:40:52 +02:00
echo "> initializing"
2024-10-21 17:46:02 +02:00
sudo bash init.sh