2019-09-13 02:35:38 +04:00
|
|
|
#!/usr/bin/env bash
|
2019-09-13 14:26:02 +04:00
|
|
|
DEVICE=/dev/nvme0n1
|
|
|
|
BOOT_PARTITION=/dev/nvme0n1p1
|
|
|
|
SWAP_PARTITION=/dev/nvme0n1p2
|
|
|
|
ROOT_PARTITION=/dev/nvme0n1p3
|
2019-09-22 22:40:08 +04:00
|
|
|
SWAP_NAME=cryptswap
|
|
|
|
ROOT_NAME=cryptnixos
|
2019-09-13 02:35:38 +04:00
|
|
|
|
2019-09-13 14:26:02 +04:00
|
|
|
gdisk $DEVICE
|
2019-09-13 02:35:38 +04:00
|
|
|
|
|
|
|
mkfs.vfat -n BOOT $BOOT_PARTITION
|
2019-09-22 22:40:08 +04:00
|
|
|
cryptsetup --type luks2 --cipher aes-xts-plain64 --key-size 256 --hash sha512 luksFormat $ROOT_PARTITION
|
|
|
|
cryptsetup luksOpen $ROOT_PARTITION $ROOT_NAME
|
|
|
|
mkfs.btrfs -f -L root /dev/mapper/$ROOT_NAME
|
|
|
|
mount -t btrfs -o compress=zstd,noatime,ssd /dev/mapper/$ROOT_NAME /mnt
|
|
|
|
btrfs subvolume create /mnt/@nixos
|
|
|
|
btrfs subvolume create /mnt/@nix-store
|
|
|
|
btrfs subvolume create /mnt/@home
|
|
|
|
btrfs subvolume create /mnt/@snapshots
|
|
|
|
umount /mnt
|
|
|
|
mount -t btrfs -o subvol=@nixos,compress=zstd,noatime,ssd /dev/mapper/$ROOT_NAME /mnt/
|
|
|
|
mkdir -p /mnt/.snapshots
|
|
|
|
mkdir -p /mnt/home
|
|
|
|
mkdir -p /mnt/nix/store
|
|
|
|
mount -t btrfs -o subvol=@snapshots,compress=zstd,noatime,ssd /dev/mapper/$ROOT_NAME /mnt/.snapshots
|
|
|
|
mount -t btrfs -o subvol=@home,compress=zstd,noatime,ssd /dev/mapper/$ROOT_NAME /mnt/home
|
|
|
|
mount -t btrfs -o subvol=@nix-store,compress=zstd,noatime,ssd /dev/mapper/$ROOT_NAME /mnt/nix/store
|
2019-09-13 02:35:38 +04:00
|
|
|
btrfs subvolume create /mnt/tmp
|
2019-09-22 22:40:08 +04:00
|
|
|
btrfs subvolume create /mnt/var
|
2019-09-13 02:35:38 +04:00
|
|
|
mkdir /mnt/boot
|
2019-09-13 14:26:02 +04:00
|
|
|
mount $BOOT_PARTITION /mnt/boot
|
2019-09-22 22:40:08 +04:00
|
|
|
# create swap
|
|
|
|
mkfs.ext2 -L $SWAP_NAME $SWAP_PARTITION 1M
|
2019-09-13 02:35:38 +04:00
|
|
|
nixos-generate-config --root /mnt/
|
|
|
|
cp ./min-config.nix /mnt/etc/nixos/configuration.nix
|
|
|
|
nano /mnt/etc/nixos/configuration.nix
|
2019-09-22 22:40:08 +04:00
|
|
|
nixos-install -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz
|