Fix installation script

This commit is contained in:
coolneng 2021-08-13 09:52:16 +01:00
parent 1de794889c
commit fcc7e151f4
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 10 additions and 38 deletions

View File

@ -8,21 +8,11 @@ partition_disk() {
mkfs.fat -F32 -n BOOT "$DISK"p1
}
create_directories() {
mkdir /mnt
mkdir -p /mnt/boot
mkdir -p /mnt/home/coolneng
mkdir -p /mnt/home/coolneng/Downloads
mkdir -p /mnt/nix
mkdir -p /mnt/tmp
}
zfs_setup() {
zpool create -f -o ashift=13 -O acltype=posixacl -O relatime=on \
-O xattr=sa -O dnodesize=legacy -O normalization=formD -O mountpoint=none \
-O canmount=off -O devices=off -R /mnt -O compression=zstd -O encryption=aes-256-gcm \
-O keyformat=passphrase -O keylocation=prompt syscea "$DISK"p2
zfs create -o mountpoint=none syscea
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false syscea/ephemeral
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false syscea/ephemeral/nix
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false -o sync=disabled -o setuid=off syscea/ephemeral/tmp
@ -32,40 +22,28 @@ zfs_setup() {
zfs create -o mountpoint=legacy -o com.sun:auto-snapshot=false syscea/stateful/root
zfs create -V 6G -b "$(getconf PAGESIZE)" -o compression=zle -o logbias=throughput -o sync=always \
-o primarycache=metadata -o secondarycache=none -o com.sun:auto-snapshot=false syscea/ephemeral/swap
mkswap -f /dev/zvol/syscea/swap && swapon /dev/zvol/syscea/swap
mkswap -f /dev/zvol/syscea/ephemeral/swap && swapon /dev/zvol/syscea/ephemeral/swap
}
mount_datasets() {
mount "$DISK"p1 /mnt/boot
mount -t zfs syscea/stateful/root /mnt
mkdir -p /mnt/boot
mount "$DISK"p1 /mnt/boot
mkdir -p /mnt/home/coolneng
mount -t zfs syscea/stateful/home /mnt/home/coolneng
mkdir -p /mnt/home/coolneng/Downloads
mount -t zfs syscea/stateful/home/downloads /mnt/home/coolneng/Downloads
mkdir -p /mnt/nix
mount -t zfs syscea/ephemeral/nix /mnt/nix
mkdir -p /mnt/tmp
mount -t zfs syscea/ephemeral/tmp /mnt/tmp
}
install_system() {
nixos-generate-config --root /mnt
nix-shell -p git nixFlakes --command "nixos-install --root /mnt --flake ."
passwd
passwd coolneng
}
deploy_dotfiles() {
chown -R coolneng:users /mnt/home/coolneng
git clone https://git.coolneng.duckdns.org/coolneng/dotfiles /mnt/home/coolneng/.dotfiles
git clone https://git.coolneng.duckdns.org/coolneng/doom.d /mnt/home/coolneng/.doom.d
git clone https://git.coolneng.duckdns.org/coolneng/pass /mnt/home/coolneng/.password-store
cd /mnt/home/coolneng/.dotfiles || exit
nix-shell -p stow --command "stow ."
}
restore_files() {
mkdir /tmp/iwd
scp zion:/vault/backups/panacea/iwd/iwd-networks.zip /tmp/iwd
cd /tmp/iwd || exit
unzip iwd-networks.zip
mv ./* /mnt/var/lib/iwd
sed -i "s/\${soundcloud_token}/PLACEHOLDER/" modules/audio.nix
mv /mnt/etc/nixos/hardware-configuration.nix modules/hardware-configuration.nix
nix-shell -p git nixFlakes --command "nixos-install --root /mnt --flake .#panacea"
}
usage() {
@ -82,16 +60,10 @@ DISK="$1"
echo "Let's start by partitioning the disk"
partition_disk
echo "Now we're creating the directories for the installation"
create_directories
echo "Starting up the ZFS machinery"
zfs_setup
echo "Mounting the horse"
mount_datasets
echo "Lift off to the NixOS planet"
install_system
echo "Adding pictures of Stallman"
deploy_dotfiles
echo "I'd just like to interject for a moment..."
restore_files
echo "All ready, time to rejoice"