My NixOS configuration
- Boot the minimal NixOS ISO image
- Create a GPT partition table with the following partitions:
/dev/EFI_PARTITION
: EFI system partition (type: EFI System, size: 1G)/dev/LUKS_PARTITION
: Encrypted root partition (type: Linux filesystem)
- Create and open the LUKS container:
cryptsetup -yv luksFormat /dev/LUKS_PARTITION cryptsetup open /dev/LUKS_PARTITION root
- Create and mount btrfs subvolumes:
mkfs.btrfs -f /dev/mapper/root mount -m -o noatime,compress=zstd /dev/mapper/root /mnt btrfs subvolume create /mnt/@data btrfs subvolume create /mnt/@data/.snapshots btrfs subvolume create /mnt/@cache btrfs subvolume create /mnt/@cache/.snapshots btrfs subvolume create /mnt/@nix btrfs subvolume create /mnt/@swap umount /mnt mount -m -o size=100%,mode=755 -t tmpfs tmpfs /mnt mount -m -o noatime,compress=zstd,subvol=@data /dev/mapper/root /mnt/persistent/data mount -m -o noatime,compress=zstd,subvol=@cache /dev/mapper/root /mnt/persistent/cache mount -m -o noatime,compress=zstd,subvol=@nix /dev/mapper/root /mnt/nix mount -m -o noatime,compress=zstd,subvol=@swap /dev/mapper/root /mnt/swap
- Create and activate swapfile:
btrfs filesystem mkswapfile -s 16G /mnt/swap/swapfile btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile # resume_offset swapon /mnt/swap/swapfile
- Format and mount EFI system partition:
mkfs.vfat /dev/EFI_PARTITION mount -m -o umask=0077 /dev/EFI_PARTITION /mnt/boot
- Install git:
nix-env -iA nixos.git
- Clone this repository:
mkdir -p /mnt/persistent/data/home/felix/ cd /mnt/persistent/data/home/felix/ git clone https://github.com/Defelo/nixos.git cd nixos
- Create a new or modify an existing host (don't forget to add new files to git).
- Install the system and reboot:
nixos-install --flake .#HOSTNAME --no-channel-copy --no-root-password reboot