update i15 config
This commit is contained in:
parent
ff97141e6f
commit
dbf36d1809
|
@ -1,9 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test -f ./flake.nix || {
|
set -xe
|
||||||
echo 'This should be run from the root of the repository!'
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
lsblk
|
lsblk
|
||||||
echo 'Enter the name of the device to WIPE and install (something like "sda"):'
|
echo 'Enter the name of the device to WIPE and install (something like "sda"):'
|
||||||
|
@ -13,60 +10,48 @@ echo 'Enter a passphrase to encrypt the disk:'
|
||||||
read -s DRIVE_PASSPHRASE
|
read -s DRIVE_PASSPHRASE
|
||||||
|
|
||||||
echo "Creating partition table..."
|
echo "Creating partition table..."
|
||||||
parted -s "/dev/${DRIVE_ID}" -- mklabel gpt || exit 1
|
parted -s "/dev/${DRIVE_ID}" -- mklabel gpt
|
||||||
|
|
||||||
echo "Creating EFI system partition..."
|
echo "Creating EFI system partition..."
|
||||||
parted -s "/dev/${DRIVE_ID}" -- mkpart ESP 1MiB 1GiB &&
|
parted -s "/dev/${DRIVE_ID}" -- mkpart ESP 1MiB 1GiB
|
||||||
parted -s "/dev/${DRIVE_ID}" -- set 1 boot on &&
|
parted -s "/dev/${DRIVE_ID}" -- set 1 boot on
|
||||||
mkfs.fat -F32 "/dev/${DRIVE_ID}1" -n NIX_BOOT || exit 1
|
mkfs.fat -F32 "/dev/${DRIVE_ID}1" -n NIX_BOOT
|
||||||
|
|
||||||
echo "Creating encrypted root partition..."
|
echo "Creating encrypted root partition..."
|
||||||
parted -s "/dev/${DRIVE_ID}" -- mkpart luks 1GiB 100% &&
|
parted -s "/dev/${DRIVE_ID}" -- mkpart luks 1GiB 100%
|
||||||
echo "$DRIVE_PASSPHRASE" | cryptsetup --batch-mode luksFormat --label CRYPT_ROOT "/dev/${DRIVE_ID}2" &&
|
echo "$DRIVE_PASSPHRASE" | cryptsetup --batch-mode luksFormat --label CRYPT_ROOT "/dev/${DRIVE_ID}2"
|
||||||
echo "$DRIVE_PASSPHRASE" | cryptsetup luksOpen "/dev/${DRIVE_ID}2" "crypt_root" && {
|
echo "$DRIVE_PASSPHRASE" | cryptsetup luksOpen /dev/disk/by-label/CRYPT_ROOT "crypt_root"
|
||||||
|
|
||||||
echo "Creating btrfs partition..."
|
echo "Creating btrfs partition..."
|
||||||
mkfs.btrfs --quiet --label NIX_ROOT /dev/mapper/"crypt_root" &&
|
mkfs.btrfs --quiet --label NIX_ROOT /dev/mapper/"crypt_root"
|
||||||
MNTPOINT=$(mktemp -d) &&
|
MNTPOINT=$(mktemp -d)
|
||||||
mount /dev/mapper/"crypt_root" "$MNTPOINT" && {
|
mount /dev/mapper/"crypt_root" "$MNTPOINT"
|
||||||
|
|
||||||
echo "Creating subvolumes..."
|
echo "Creating subvolumes..."
|
||||||
btrfs subvolume create "$MNTPOINT"/main
|
btrfs subvolume create "$MNTPOINT"/nixos
|
||||||
btrfs subvolume create "$MNTPOINT"/home
|
btrfs subvolume create "$MNTPOINT"/home
|
||||||
btrfs subvolume create "$MNTPOINT"/swap
|
btrfs subvolume create "$MNTPOINT"/swap
|
||||||
|
|
||||||
}
|
echo "Closing btrfs partition..."
|
||||||
|
umount -Rl "$MNTPOINT"
|
||||||
|
rm -rf "$MNTPOINT"
|
||||||
|
|
||||||
echo "Closing btrfs partition..."
|
echo "Mounting root btrfs submodule to '$MNTPOINT' ..."
|
||||||
umount -Rl "$MNTPOINT" &&
|
MNTPOINT=$(mktemp -d)
|
||||||
rm -rf "$MNTPOINT"
|
mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT" -o subvol=nixos,noatime,compress=zstd
|
||||||
|
|
||||||
echo "Mounting root btrfs submodule..."
|
echo "Creating and mounting EFI system partition mountpoint..."
|
||||||
MNTPOINT=$(mktemp -d) &&
|
mkdir -p "$MNTPOINT/boot/efi"
|
||||||
mount /dev/mapper/"crypt_root" "$MNTPOINT" -o subvol=main,noatime,compress=zstd && {
|
mount /dev/disk/by-label/NIX_BOOT "$MNTPOINT/boot/efi"
|
||||||
|
|
||||||
echo "Creating and mounting EFI system partition mountpoint..."
|
echo "Creating home partition mountpoint..."
|
||||||
mkdir -p "$MNTPOINT/boot/efi" &&
|
mkdir -p "$MNTPOINT/home"
|
||||||
mount "/dev/${DRIVE_ID}1" "$MNTPOINT/boot/efi" &&
|
mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT/home" -o subvol=home,noatime,compress=zstd
|
||||||
|
|
||||||
echo "Creating home partition mountpoint..." &&
|
echo "Swapfile"
|
||||||
mkdir -p "$MNTPOINT/home" &&
|
mkdir -p "$MNTPOINT/swap"
|
||||||
mount /dev/mapper/"crypt_root" "$MNTPOINT/home" -o subvol=home,noatime,compress=zstd &&
|
mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT/home" -o subvol=swap,noatime
|
||||||
|
|
||||||
echo "Swapfile" &&
|
echo "Installing system..."
|
||||||
mkdir -p "$MNTPOINT/swap" &&
|
nixos-generate-config --root "$MNTPOINT"
|
||||||
mount /dev/mapper/"crypt_root" "$MNTPOINT/home" -o subvol=swap,noatime &&
|
nixos-install --root "$MNTPOINT"
|
||||||
|
|
||||||
echo "Installing system..." &&
|
|
||||||
nixos-install --flake .#i15 --root "$MNTPOINT"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Closing root btrfs submodule..."
|
|
||||||
umount -Rl "$MNTPOINT" &&
|
|
||||||
rm -rf "$MNTPOINT"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Closing encrypted root partition..."
|
|
||||||
cryptsetup close "crypt_root"
|
|
||||||
|
|
Loading…
Reference in a new issue