Note
This instruction is for future me and for educational purposes. It is not intended to enable you to install my config. I mean, you can try of course, but it will not work without my secrets so you will have to adjust at least that, and possibly something more.
Installation consists of two phases:
- Using
nixos-anywhere
to install a minimal installer environment into the target machine with NixOS installer ISO booted. - Setting up the necessary secrets and rebuilding full system and home configuration on the target machine.
The process is mostly automated with ./scripts/installer.sh
script.
- Boot the installer ISO on the target machine.
- Set a temporary password with
passwd
. - Check the IP address of the target machine with
ip a
.
If you're installing on a new machine and don't have the hardware configuration file.
Obtain a hardware-configuration.nix
:
./scripts/installer.sh hardware {ip} {hostname} {username}
Enter the temporary password if prompted.
This will copy the file into ./installer/{hostname}
directory.
Put this file in the right ./hosts
subdirectory for the target host.
Partition the disk and install the installer environment ({hostname}-installer
in flake's nixosConfigurations
output):
Caution
This will wipe the drive on the target machine.
./scripts/installer.sh bootstrap {ip} {hostname} {username}
Enter the temporary password if prompted. Set the LUKS password if prompted.
-
Reboot into UEFI interface and setup Secure Boot:
- Enable Secure Boot.
- Erase all keys.
- Enable setup mode.
-
Reboot into the system.
-
Generate and enroll Secure Boot keys:
./scripts/installer.sh secureboot {ip} {hostname} {username}
-
Generate and fetch public keys from the target machine:
./scripts/installer.sh keys {ip} {hostname} {username}
This will copy the public key files into
./installer/{hostname}
directory. It will also print the keys both in SSH and in age format. -
Use the public keys to prepare all the necessary secrets. Remember to:
-
Prepare new secret files for this host.
-
Update existing secret files with
sops updatekeys
. -
Authorize the target host keys to access the secrets repo.
-
Update the secrets in the lockfile to the latest commit:
nix flake update my-secrets
-
-
Start the system config rebuild:
./scripts/installer.sh install {ip} {hostname} {username}
-
Start the home config rebuild:
./scripts/installer.sh home {ip} {hostname} {username}
-
Reboot.
-
SSH into the target machine:
ssh {username}@{hostname}
. -
Setup LUKS auto unlocking with TPM:
sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+2+7+12 --wipe-slot=tpm2 {partition}
Enter the LUKS password when prompted.
-
Reboot. The disk should be decrypted automatically.