#!/usr/bin/env sh sudo -i loadkeys de lsbkl # Partitioning read -p "Create partitions table? DELETES ALL DATA! (j/N): " answer if [ "$answer" = "j" ] || [ "$answer" = "J" ]; then # GPT-partition table parted /dev/sda -- mklabel gpt # EFI-partition (512 MB) parted /dev/sda -- mkpart esp fat32 1MB 512MB parted /dev/sda -- set 1 esp on # Swap-partition (8 GB) parted /dev/sda -- mkpart swap linux-swap 512MB 8626MB # Root-partition (ca. 45 GB) parted /dev/sda -- mkpart root ext4 8636MB 40000MB # Home-partition (Rest) parted /dev/sda -- mkpart home ext4 40000MB 100% fi # Check results parted /dev/sda -- print mkfs.fat -F 32 -n boot /dev/sda1 mkswap -L swap /dev/sda2 mkfs.ext4 -L nixos /dev/sda3 read -p "Format Home-partition? Deletes all userdata! (j/N): " answer if [ "$answer" = "j" ] || [ "$answer" = "J" ]; then # Format home-partition mkfs.ext4 -L home /dev/sda4 fi # Mount partitions mount /dev/disk/by-label/nixos /mnt mkdir /mnt/boot mount -o umask=077 /dev/disk/by-label/boot /mnt/boot mkdir -p /mnt/home mount /dev/disk/by-label/home /mnt/home # Activate swap swapon /dev/disk/by-label/swap nixos-generate-config --root /mnt nixos-install # If root password wasn't set because the installation needed to be restarted. read -p "Set Root-password with nixos-enter? (j/N): " answer if [ "$answer" = "j" ] || [ "$answer" = "J" ]; then nixos-enter --root '/mnt' passwd fi