The official NixOS.org site has very good documentation. This is a condensed version for myself.
https://nixos.org/manual/nixos/stable/#sec-booting-from-usb
You will need to sudo
or sudo -i
the majority of these commands.
- Flash the minimal image to a USB device from Linux
dd if=<nixos-minimal-image.iso> of=/path/to/usb bs=4M conv=fsync
- Boot from the USB on the target device
- Start wpa_supplicant >
systemctl start wpa_supplicant
- Enable a wireless network >
wpa_cli
add_network 0
set_network 0 ssid "SSID"
set_netwwork 0 psk "PSK"
set_network 0 key_mgmt WPA-PSK
enable_network 0
-
lsblk
- to identify connected drives -
Format the disk >
fdisk /dev/path-to-target
-
Create a new GPT partition table >
g
-
Create a new partition >
n
-
Create the following structure at minimum
|-/dev/sda1 efi > t > 1
|-/dev/sda2 linux-filesystem
|-/dev/sda3 (optional)swap t > 19
- Write changes to disk >
w
- For EFI >
mkfs.fat -F 32 /dev/sda1
- For Primary >
mkfs.ext4 /dev/sda2
- For swap >
mkswap -L swap /dev/sda3
>sudo swapon
- Format with LUKS >
cryptsetup luksFormat /dev/sda2
- Open with LUKS >
cryptsetup luksOpen /dev/sda2 cryptroot
- Format mapped cryptroot >
mkfs.ext4 -L nixos /dev/mapper/cryptroot
- Mount the primary partition to
/mnt
>mount /dev/disk/by-label/nixos /mnt
- Make boot dir >
mkdir -p /mnt/boot
- Mount boot >
mount /dev/sda1 /mnt/boot
- Generate >
nixos-generate-config --root /mnt
- Edit
configuration.nix
>nano /mnt/etc/nixos/configuration.nix
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ]
boot.loader.systemd-boot.enalbe = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.wireless.enable = true;
networking.wireless.interface = [ "interface" ];
networking.wireless.userControlled.enable = true;
users.users.user = {
isNormalUser = true;
extraGroups = [ "wheel" ];
initialPassword = "temp123";
};
system.stateVersion = "23.05";
}
swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];
- Install >
nixos-install
- You will be prompted for a root password afterwards.
- Reboot >
reboot