Decide how you want to install NixOS
There are two supported paths to install NixOS documented in this
book. Both end at the same place: a per-host ~/nixos flake repo that
depends on sway-home, which you can edit and then apply with admin upgrade from then on. Pick whichever installation method suits your
hardware and taste.
Use the official NixOS installer
Install stock NixOS from the official graphical installer ISO, then
run setup-host --adopt to build the ~/nixos repo on top of the
existing install. This is the easiest option when you already have a
monitor and keyboard (or an IP KVM) attached to the target machine,
and you do not need to build anything on another machine first. The
graphical installer partitions the disk for you; the resulting layout
is reused as-is, so there is no declarative disko.nix for the disks.
The graphical installer only offers basic single-disk layouts. If you
want anything more elaborate – a btrfs RAID across multiple disks,
LUKS on top of mdraid, LVM, or any other multi-device or nested setup
– use the custom installer ISO below, which lays the disk out with
disko and drops the resulting disko.nix into your host repo where
you can edit it to express those layouts declaratively.
Build a custom installer ISO
Build a headless, SSH-ready installer ISO with your public keys (and optionally your WiFi credentials) baked in, then boot the target machine from it and drive the whole install over SSH. The disk is partitioned declaratively with disko, so the layout is captured in your host repo. This is the best option for headless machines, and for installing several boxes on the same network. It does require an existing machine with Nix installed to build the ISO first (it does not have to be NixOS).