-
Run the live image of NixOS.
-
Switch to root:
sudo -i
-
Connect to the network following the guide.
It could be useful to read the guide while doing installation:
screen nixos-help # C-a S # C-a tab # C-a c # Switch region with C-a tab
-
Partition the disk.
SWAP=8GiB dev=/dev/sda
Example for UEFI systems:
parted $dev -- mklabel gpt parted $dev -- mkpart primary 512MiB -$SWAP parted $dev -- mkpart primary linux-swap -$SWAP 100% parted $dev -- mkpart ESP fat32 1MiB 512MiB parted $dev -- set 3 esp on
-
Optionally encrypt the main partition:
cryptsetup luksFormat "$dev"1 cryptsetup open "$dev"1 nixenc
-
Format the partitions:
mkfs.btrfs -L root /dev/mapper/nixenc mkswap -L swap "$dev"2 swapon "$dev"2 mkfs.fat -F 32 -n boot "$dev"3
-
Optionally create subvolumes (btrfs only):
mount -t btrfs /dev/mapper/nixenc /mnt/ btrfs subvol create /mnt/nixos umount /mnt mount -t btrfs -o subvol=nixos /dev/mapper/nixenc /mnt btrfs subvol create /mnt/home
-
Mount the boot partition:
mkdir /mnt/boot mount "$dev"3 /mnt/boot
-
Generate config and install:
nixos-generate-config --root /mnt nixos-install