From f06265c005ede7b9c5c07148a3dd0e39293424a5 Mon Sep 17 00:00:00 2001 From: Christian Harke Date: Fri, 22 Sep 2023 18:23:06 +0200 Subject: [PATCH] Make disk encryption optional --- lib/apps/nixos-install.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/apps/nixos-install.sh b/lib/apps/nixos-install.sh index baf39a3a..e7b4a34a 100644 --- a/lib/apps/nixos-install.sh +++ b/lib/apps/nixos-install.sh @@ -95,11 +95,13 @@ partition() { } echo '12' -create_volumes() { - _log "[create_volumes] Encrypting LVM partition..." +encrypt_partition() { + _log "[encrypt_partition] Encrypting LVM partition..." cryptsetup luksFormat "${LVM_PARTITION}" cryptsetup luksOpen "${LVM_PARTITION}" "${LVM_PV}" +} +create_volumes() { _log "[create_volumes] Creating LVM volumes..." pvcreate "/dev/mapper/${LVM_PV}" vgcreate "${LVM_VG}" "/dev/mapper/${LVM_PV}" @@ -160,9 +162,20 @@ install() { ### Pull the trigger echo '16' -# shellcheck disable=SC2310 -if _read_boolean "Do you want to DELETE ALL PARTITIONS?" N; then +DO_PARTITION="$(_read_boolean "Do you want to DELETE ALL PARTITIONS?" N)" +readonly DO_PARTITION +if "${DO_PARTITION}"; then partition +fi + +echo '16-1' +DO_ENCRYPT="$(_read_boolean "Do you want to ENCRYPT THE DISK?" N)" +readonly DO_ENCRYPT +if "${DO_ENCRYPT}"; then + encrypt_partition +fi + +if "${DO_PARTITION}"; then create_volumes create_filesystems fi @@ -177,8 +190,9 @@ if [[ ${LVM_PV_NUM_ACTIVE} -lt 1 ]]; then fi echo '18' -# shellcheck disable=SC2310 -if _read_boolean "Do you want to INSTALL NixOS now?" N; then +DO_INSTALL="$(_read_boolean "Do you want to INSTALL NixOS now?" N)" +readonly DO_INSTALL +if "${DO_INSTALL}"; then install fi