68 lines
1.9 KiB
Bash
68 lines
1.9 KiB
Bash
#!/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
|
|
echo -n "> what type of thing? o for BIOS (automatic), g for EFI (needs further config): "
|
|
read mode
|
|
sudo fdisk "/dev/$drive" << EOF
|
|
$mode
|
|
n
|
|
p
|
|
1
|
|
|
|
+512M
|
|
$(if [ "$mode" = o ] ; then echo -n a ; else echo -en "t\n1" ; fi)
|
|
n
|
|
p
|
|
2
|
|
|
|
-100M
|
|
w
|
|
EOF
|
|
if [ $? != 0 ] ; then exit 1 ; fi
|
|
sleep 1
|
|
echo "> created partition table on /dev/$drive with /boot and /."
|
|
sudo mkfs.fat /dev/$drive*1 || exit 1 # /dev/sda 1 or /dev/nvme0n1 p1 => *1 instead of just 1
|
|
sudo cryptsetup luksFormat /dev/$drive*2 || exit 1
|
|
sudo cryptsetup open /dev/$drive*2 cryptroot || exit 1
|
|
sudo mkfs.ext4 /dev/mapper/cryptroot || exit 1
|
|
echo "> formatted."
|
|
sudo mkdir /mnt
|
|
sudo mount /dev/mapper/cryptroot /mnt || exit 1
|
|
sudo mkdir /mnt/boot
|
|
sudo mount /dev/$drive*1 /mnt/boot || exit 1
|
|
echo "> mounted."
|
|
echo "> generating config"
|
|
sudo nixos-generate-config --root /mnt
|
|
cd /mnt/etc/nixos
|
|
|
|
sudo loadkeys de
|
|
echo -n "hostname: "
|
|
sudo sed -i -E "s/^}\$/ boot.loader.grub.device = \"\/dev\/$drive\";\n networking.hostName = \"$(head -n1)\";\n}/" hardware-configuration.nix
|
|
sudo sed -i -E 's/\[ (\(modulesPath)/[ #marker.inclusions#\n \1/g' hardware-configuration.nix
|
|
if [ "$mode" = g ] ; then
|
|
sudo sed -i -E 's/(#marker.inclusions#)/.\/efi.nix \1/g' hardware-configuration.nix
|
|
fi
|
|
echo "> installing git"
|
|
nix-env -i git > /dev/null || exit 1
|
|
echo "> downloading tudbut/nix-setup"
|
|
sudo git clone https://git.tudbut.de/tudbut/nix-setup
|
|
sudo rm configuration.nix
|
|
pushd nix-setup ; sudo mv $(ls -a) .. ; popd
|
|
echo "> initializing"
|
|
sudo bash init.sh
|