diff options
-rwxr-xr-x | public/install-nixos.sh | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/public/install-nixos.sh b/public/install-nixos.sh index b1eb126..95030b5 100755 --- a/public/install-nixos.sh +++ b/public/install-nixos.sh @@ -58,9 +58,8 @@ SERVER="https://euandre.org/dotfiles" yellow "Downloading Nix files..." TMP_DIR="$(mktemp -d)" -wget -O "${TMP_DIR}/configuration.nix" "${SERVER}/configuration.nix" -wget -O "${TMP_DIR}/hardware-configuration.nix" "${SERVER}/hardware-configuration.nix" -wget -O "${TMP_DIR}/template.nix" "${SERVER}/template.nix" +wget -O "${TMP_DIR}/configuration.nix" "${SERVER}/configuration.nix" +wget -O "${TMP_DIR}/template.nix" "${SERVER}/template.nix" green "Done." yellow "Creating content of '/etc/nixos/local-configuration.nix'..." @@ -81,4 +80,50 @@ yellow "Moving presented content to '/etc/nixos/local-configuration.nix'..." echo mv "${TMP_DIR}/local-configuration.nix" /etc/nixos/local-configuration.nix green "Done." -# fdisk +yellow "Partitioning '${DEVICE}'..." +# Create a GPT partition table. +parted "${DEVICE}" -- mklabel gpt +# Add the root partition. This will fill the disk except for the end part, where the swap will live, and the space left in front (512MiB) which will be used by the boot partition. +parted "${DEVICE}" -- mkpart primary 512MiB -8GiB +# Add a swap partition of 8GiB. +parted "${DEVICE}" -- mkpart primary linux-swap -8GiB 100% +# Add the boot partition. NixOS by default uses the ESP (EFI system partition) as its /boot partition. It uses the initially reserved 512MiB at the start of the disk. +parted "${DEVICE}" -- mkpart ESP fat32 1MiB 512MiB +parted "${DEVICE}" -- set 3 boot on +green "Done." + +yellow "Configuring LUKS encryption on '${DEVICE}3'..." +cryptsetup luksFormat "${DEVICE}3" +cryptsetup luksOpen "${DEVICE}3" enc-pv +pvcreate /dev/mapper/enc-pv +vgcreate vg /dev/mapper/enc-pv +lvcreate -n swap vg -L 10G +lvcreate -n root vg -l 100%FREE +green "Done." + +yellow "Formatting '${DEVICE}'..." +mkfs.vfat -n BOOT "${DEVICE}2" +mkfs.ext4 -L root /dev/vg/root +mkswap -L swap /dev/vg/swap +green "Done." + +yellow "Mounting and activating swap..." +mount /dev/vg/root /mnt +mkdir /mnt/boot +mount "${DEVICE}2" /mnt/boot +swapon /dev/vg/swap +green "Done." + +yellow "Generating '/etc/nixos/*' Nix files'..." +nixos-generate-config --root /mnt +mv /etc/nixos/configuration.nix /etc/nixos/bkp-configuration.nix +mv "${TMP_DIR}/configuration.nix" /etc/nixos/configuration.nix +green "Done." + +blue "Now inspect '/etc/nixos/configuration.nix', " +yellow "Installing NixOS!" +nixos-install +green "Done." + +yellow "Rebooting..." +reboot |