From e6edc3f887d29e7bde73a848ec27c2a52b0bc0b3 Mon Sep 17 00:00:00 2001 From: Matthew_Cash Date: Sun, 22 Dec 2024 14:39:56 -0800 Subject: [PATCH] Remove disk installation from install script --- install.sh | 79 +++++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 61 deletions(-) diff --git a/install.sh b/install.sh index 9a49173..5565ae5 100755 --- a/install.sh +++ b/install.sh @@ -1,74 +1,31 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash parted util-linux cryptsetup systemd kmod lvm2 coreutils +#!nix-shell -i bash -p bash util-linux coreutils nixos-install mkpasswd -# Set this to either the by-path/ or by-id/ path for the disk -disk=/dev/disk/by-path/pci-0000:00:0e.0-pci-10000:e1:00.0-nvme-1 - -# Partition disk - -parted $disk mklabel gpt -parted $disk mkpart efi 0% 500M -parted $disk set 1 esp on -parted $disk mkpart lvm 500M 100% - -# Setup EFI partition - -mkfs.vfat ${disk}-part1 -n efi - -# Setup Encrypted LVM Partition - -cryptsetup luksFormat ${disk}-part2 -cryptsetup luksOpen ${disk}-part2 main -cryptsetup config ${disk}p2 --label crypt-main -systemd-cryptenroll --tmp2-device=auto --tpm2-pcrs=0+7 /dev/disk/by-label/crypt-main - -# Setup LVM - -modprobe dm_thin_pool - -pvcreate ${disk}-part2 -vgcreate main ${disk}-part2 - -lvcreate -T -l 95%FREE main -n thin-main - -lvcreate -V 1T --thinpool thin-main main -n nix -lvcreate -V 32G --thinpool thin-main main -n swap -lvcreate -V 1T --thinpool thin-main main -n persist -lvcreate -V 1T --thinpool thin-main main -n crypt-home-matthew - -# Setup Encrypted Home Volume - -cryptsetup luksFormat /dev/main/crypt-home-matthew -cryptsetup luksOpen /dev/main/crypt-home-matthew home-matthew -cryptsetup config /dev/main/crypt-home-matthew --label crypt-home-matthew - -mkfs.btrfs /dev/mapper/home-matthew -L home-matthew - -# Setup Persist file system +# Mount filesystems -mkfs.btrfs /dev/main/persist -L persist +mkdir -p /installroot +mount -t tmpfs none /installroot +mkdir -p /installroot/{boot,nix,mnt/{persist,home}} -# Setup Nix file system +mount /dev/disk/by-partlabel/disk-main-efi /installroot/boot +mount /dev/main/nix /installroot/nix +mount /dev/main/persist /installroot/mnt/persist -mkfs.btrfs /dev/main/nix -L nix +mkdir -p /installroot/mnt/home/matthew +mount /dev/mapper/home-matthew /installroot/mnt/home/matthew -# Mount filesystems +# Create password file directory -mkdir -p /mnt -mount -t tmpfs none /mnt -mkdir -p /mnt/{boot,nix,mnt/{persist,home}} +mkdir -p /installroot/mnt/persist/pwd -mount /dev/disk/by-label/efi /mnt/boot -mount /dev/disk/by-label/nix /mnt/nix -mount /dev/disk/by-label/persist /mnt/mnt/persist +mkpasswd -m sha-512 > /installroot/mnt/persist/pwd/matthew -mkdir -p /mnt/mnt/home/matthew -mount /dev/disk/by-label/home-matthew /mnt/mnt/home/matthew +# Copy this repo to the new installation -# Create password file directory +cp -r . /installroot/mnt/persist/$(basename $(pwd)) -mkdir -p /mnt/mnt/persist/pwd +# Install NixOS -# Copy this repo to the new installation +nixos-install --no-root-passwd --root /installroot --flake path:. -cp -r . /mnt/mnt/persist/ +nixos-enter --root /installroot -c 'chown matthew:users /mnt/home/matthew'