diff options
author | EuAndreh <eu@euandre.org> | 2019-06-01 09:15:26 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2019-06-01 09:15:26 -0300 |
commit | c19fadf9062341f8129a8ff83e897cc06f8c2145 (patch) | |
tree | 73deae71b8afd945fec55a95130d3674602c1ebd | |
parent | Add fallback null value to the shelcheck derivation input (diff) | |
download | dotfiles-c19fadf9062341f8129a8ff83e897cc06f8c2145.tar.gz dotfiles-c19fadf9062341f8129a8ff83e897cc06f8c2145.tar.xz |
WIP: format, encrypt and partition the disk in install-nixos.sh
The LUKS encryption and disk formatting commands are coherent, but the
partitionig isn't. I just copied them from the manual to get a rough idea of how
it should look like.
-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 |