# NixOS install (LUKS, Secure Boot, TPM unlock) # Partition, encrypt, mount # As root (sudo -i). gdisk DISK: p1 EFI system (ef00), p2 Linux (8300) for the rest. No swap partition. mkfs.fat -F32 -n boot DISKp1 cryptsetup luksFormat DISKp2 # TRIM through LUKS, saved in its header. The name must be cryptroot: the config unlocks it by that name. cryptsetup open --allow-discards --persistent DISKp2 cryptroot mkfs.ext4 -L nixos /dev/mapper/cryptroot mount /dev/mapper/cryptroot /mnt mount --mkdir -o umask=077 DISKp1 /mnt/boot # Install nixos-generate-config --root /mnt curl -L nix.b3n.me -o configuration.nix cp configuration.nix /mnt/etc/nixos/ # In /mnt/etc/nixos/configuration.nix (the stub): set hostName and isLaptop. # The ISO's Nix has flakes off and the config uses getFlake, hence the option. nixos-install --option extra-experimental-features 'nix-command flakes' nixos-enter --root /mnt -c 'passwd ben' reboot # Dotfiles # As ben, on a TTY (the desktop has no config yet). git clone --bare https://github.com/Bueezi/dotfiles.git ~/.dotfiles git --git-dir=$HOME/.dotfiles --work-tree=$HOME config --local status.showUntrackedFiles no git --git-dir=$HOME/.dotfiles --work-tree=$HOME checkout # rb now builds from ~/.config/nix, not the GitHub copy rb # for cu: pushes, the private ~/Documents/sync gh auth login cu # Then log in to the desktop again (quit Umbriel: Mod+Shift+M). # Secure Boot (Lanzaboote) # The first boot made the keys (/var/lib/sbctl). systemd-boot enrolls them, with Microsoft's # (the GPU's option ROM is signed by them), at a boot with the firmware in Setup Mode. systemctl reboot --firmware-setup # In the firmware: delete ONLY the Platform Key (PK). Never "Clear Secure Boot Keys" / "clear all keys": # that also wipes the dbx (the revoked boot loaders). Lost it anyway: restore the factory keys first. # ASRock (desktop, A620M Pro RS): Advanced (F6) > Security > Secure Boot > Secure Boot Mode [Custom] # > Key Management > Platform Key(PK) > Delete. F10. # Boot: "Enrolling secure boot keys from directory: \loader\keys\auto". Press nothing, let it count down. # Back in the firmware: Secure Boot [Enabled]. ASRock: keep Secure Boot Mode on [Custom] # ([Standard] reloads ASRock's own keys over yours). F10. # Check: Setup Mode Disabled, Secure Boot Enabled, Vendor Keys "microsoft" (no "builtin-PK": the vendor's PK is still there) sbctl status # a dbx-... line, or the dbx is gone ls /sys/firmware/efi/efivars | grep '^dbx-' sudo sbctl verify # The factory dbx is old: take Microsoft's current one (UEFI dbx), then reboot. fwupdmgr update # Ventoy then needs its key enrolled (MOK), or Secure Boot off, to boot. # TPM unlock # Last: it binds to PCR 7 (Secure Boot state, keys, dbx), which every step above changes. # Asks the LUKS passphrase once; after that no passphrase at boot. sudo systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=7 $(lsblk -sno PATH,TYPE /dev/mapper/cryptroot | awk '$2=="part"{print $1}') # The passphrase comes back when PCR 7 changes (Secure Boot off, new keys, a BIOS or dbx update): # type it, then the same command with --wipe-slot=tpm2 added. Undo: only --wipe-slot=tpm2 and the partition.