i15: update config

This commit is contained in:
Leonardo Eugênio 2022-12-20 09:32:20 -03:00
parent dbf36d1809
commit 08f6dadc40
2 changed files with 24 additions and 12 deletions

View file

@ -28,13 +28,19 @@ in {
fileSystems."/" = { fileSystems."/" = {
device = "/dev/disk/by-label/NIX_ROOT"; device = "/dev/disk/by-label/NIX_ROOT";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=nixos" ] ++ btrfs_options; options = [ "subvol=@nixos" ] ++ btrfs_options;
}; };
fileSystems."/home" = { fileSystems."/home" = {
device = "/dev/disk/by-label/NIX_ROOT"; device = "/dev/disk/by-label/NIX_ROOT";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=home" ] ++ btrfs_options; options = [ "subvol=@home" ] ++ btrfs_options;
};
fileSystems."/swap" = {
device = "/dev/disk/by-label/NIX_ROOT";
fsType = "btrfs";
options = [ "subvol=@swap" ] ++ btrfs_options;
}; };
swapDevices = [{ swapDevices = [{

View file

@ -2,6 +2,11 @@
set -xe set -xe
settle() {
udevadm trigger --subsystem-match=block
udevadm settle
}
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"):'
read DRIVE_ID read DRIVE_ID
@ -20,6 +25,7 @@ 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"
settle
echo "$DRIVE_PASSPHRASE" | cryptsetup luksOpen /dev/disk/by-label/CRYPT_ROOT "crypt_root" echo "$DRIVE_PASSPHRASE" | cryptsetup luksOpen /dev/disk/by-label/CRYPT_ROOT "crypt_root"
echo "Creating btrfs partition..." echo "Creating btrfs partition..."
@ -28,9 +34,9 @@ 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"/nixos 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..." echo "Closing btrfs partition..."
umount -Rl "$MNTPOINT" umount -Rl "$MNTPOINT"
@ -38,20 +44,20 @@ rm -rf "$MNTPOINT"
echo "Mounting root btrfs submodule to '$MNTPOINT' ..." echo "Mounting root btrfs submodule to '$MNTPOINT' ..."
MNTPOINT=$(mktemp -d) MNTPOINT=$(mktemp -d)
mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT" -o subvol=nixos,noatime,compress=zstd mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT" -o subvol=@nixos,noatime,compress=zstd
echo "Creating and mounting EFI system partition mountpoint..." echo "Creating and mounting EFI system partition mountpoint..."
mkdir -p "$MNTPOINT/boot/efi" mkdir -p "$MNTPOINT/boot"
mount /dev/disk/by-label/NIX_BOOT "$MNTPOINT/boot/efi" mount /dev/disk/by-label/NIX_BOOT "$MNTPOINT/boot"
echo "Creating home partition mountpoint..." echo "Creating home partition mountpoint..."
mkdir -p "$MNTPOINT/home" mkdir -p "$MNTPOINT/home"
mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT/home" -o subvol=home,noatime,compress=zstd mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT/home" -o subvol=@home,noatime,compress=zstd
echo "Swapfile" echo "Swapfile"
mkdir -p "$MNTPOINT/swap" mkdir -p "$MNTPOINT/swap"
mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT/home" -o subvol=swap,noatime mount /dev/disk/by-label/NIX_ROOT "$MNTPOINT/swap" -o subvol=@swap,noatime
echo "Installing system..." # echo "Installing system..."
nixos-generate-config --root "$MNTPOINT" nixos-generate-config --root "$MNTPOINT"
nixos-install --root "$MNTPOINT" # nixos-install --root "$MNTPOINT"