Build on any x86_64 Linux system with Nix:
nix build .#installer-isosudo -i
lsblk -f
fdisk /dev/<target-disk>Use GPT for a new partition table:
/boot +512M EFI System
/ +120G Linux filesystem
/home remaining Linux filesystem
Skip creating a new EFI partition when reusing an existing one. Check partition names before formatting:
# Only for a newly created EFI partition
mkfs.fat -F 32 -n NIXOS_BOOT /dev/<efi-partition>
# For an existing FAT EFI partition without a label
fatlabel /dev/<efi-partition> NIXOS_BOOT
mkfs.ext4 -L nixos-root /dev/<root-partition>
mkfs.ext4 -L nixos-home /dev/<home-partition>Mount filesystems and install the system already contained in the ISO:
mount /dev/<root-partition> /mnt
mount --mkdir /dev/<efi-partition> /mnt/boot
mount --mkdir /dev/<home-partition> /mnt/home
install-bootstrap <hostname> <username>
rebootInstallation does not require network access.
To update an existing bootstrap from a newer live USB, mount the existing filesystems without formatting them, then run:
install-bootstrap
rebootThis updates only the installed NixOS generation and preserves hostname, users,
passwords, SSH keys, hardware.nix, and /home.
Connect Wi-Fi if needed:
impalaTransfer files and connect from a trusted machine:
sudo scp /path/to/config.yaml <username>@<hostname>.local:~/config.yaml
scp <username>@<hostname>.local:~/hardware.nix /tmp/hardware.nix
ssh <username>@<hostname>.localInstall a Mihomo configuration and start the service:
sudo install -Dm600 ~/config.yaml /var/lib/private/mihomo/config.yaml
sudo systemctl restart mihomo
clashtuiOn the new machine, print host and user public keys:
cat /etc/ssh/ssh_host_ed25519_key.pub
cat ~/.ssh/id_ed25519.pubOn a trusted machine, add both keys to secrets/keys.nix, add the user key to
GitHub, then rekey and push:
cd ~/.config/nixos
git pull --ff-only
mkdir hosts/<hostname>
cp hosts/host-template.nix hosts/<hostname>/default.nix
cp /tmp/hardware.nix hosts/<hostname>
$EDITOR # secrets/keys.nix hosts/<hostname>/default.nix ...
(cd secrets && agenix -r)
git add .
git commit -m "feat: add new host: <hostname>"
git pushOn the new machine:
ssh -T git@github.com
git clone git@github.com:dokee39/terra.nixos.git ~/nixos-config
sudo cp -a ~/nixos-config/. /etc/nixos/
sudo chown -R "$USER":users /etc/nixos
sudo nixos-rebuild switch --flake /etc/nixos#<hostname>
rm -v -rf ~/nixos-config ~/config.yaml ~/hardware.nix