I want to install several machines with the same configuration. So I wonder, if it is possible to boot a minimal NixOS image from an USB stick and directly call nixos-rebuild switch without installing NixOS first?
What is the best practice for this?
I think you can do command-line install with whatever configuration you wish to supply.
nixos-anywhere is well suited for this. I would install manually (or even with disko) on one system (preferably the most powerful with the best internet speeds), then use nixos-anywhere to deploy to the rest. With disko, it will automatically format the drives. If you could use PXE boot (or just use a lot of USBs lol) and know the IPs of the devices, you could install on all of them at once with this method.
For my physical devices (laptops/ RPIs) I’ve build an USB based image with some modifications (mostly SSH + users + WiFi) to boot them up.
For servers/ VMs that can be managed via an API I tied
kexec module into my terraform/ terranix configuration and everything happens automatically.
Most recent success: one command to install a new laptop with ZFS encryption enabled