If possible, do this on the previous host:
-
Backup any data which isn't already backed up somewhere else.
- Shell history (zsh)
- Music under $XDG_MUSIC_DIR (I have a backup, but make sure it's really up-to-date)
- Chrome bookmarks (They should all be in my bookmark manager)
- Firefox bookmarks should be synced with my Mozilla account, but double-check
- Files under $XDG_DOWNLOAD_DIR
-
Commit and push changes for my Git repositories.
- dotfiles
- Everything under $XDG_PROJETS_DIR
-
Switch to the root user.
sudo su -
-
Download this repository as a ZIP archive and extract its content at
/tmp/dotfiles
(with-L
,curl
follows redirects)curl -L https://github.com/dmarcoux/dotfiles/archive/refs/heads/main.zip --output /tmp/dotfiles.zip && unzip /tmp/dotfiles.zip -d /tmp && mv /tmp/dotfiles-main /tmp/dotfiles
-
Set the hostname for the new host, and create its directory in the dotfiles.
export HOSTNAME="PICK_A_NAME" && mkdir -p "/tmp/dotfiles/hosts/$HOSTNAME"
-
To partition, format, and mount the disks, I use disko. Create or adapt one of the disko configurations from the dotfiles. The disko configuration must be at
/tmp/dotfiles/hosts/$HOSTNAME/disko-config.nix
. Either way, ensure the disk names match whatlsblk
outputs.Example of
lsblk
outputNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 1.8T 0 disk nvme0n1 259:0 0 476.9G 0 disk
In this example, the disk names are
/dev/sda
and/dev/nvme0n1
.Example of a disko configuration and where to put the disk names
# ... main = { type = "disk"; device = "/dev/sda"; content = { type = "gpt"; # ...
-
If encrypting disks with LUKS:
5.1. Wipe disks before proceeding
dd if=/dev/zero of=DISK bs=1M status=progress
5.2. Set passphrase to decrypt disks on boot
echo -n "password" > /tmp/secret.key
-
Run disko to partition, format and mount the disks.
This will erase any existing data on the disks.
nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount "/tmp/dotfiles/hosts/$HOSTNAME/disko-config.nix"
-
Create
configuration.nix
for the system, but without the filesystems. Those are handled bydisko
.nixos-generate-config --no-filesystems --root /mnt
-
Move the dotfiles and the generated Nix files to the mounted disks.
mv /tmp/dotfiles /mnt/etc/nixos/ && mv /mnt/etc/nixos/*.nix "/mnt/etc/nixos/dotfiles/hosts/$HOSTNAME/"
-
Add the new host inside
nixosConfigurations = { ... }
.vim /mnt/etc/nixos/dotfiles/flake.nix
-
Edit the Nix configuration files for the host.
vim "/mnt/etc/nixos/dotfiles/hosts/$HOSTNAME/*.nix"
-
Install NixOS for the new host.
nixos-install --flake "/mnt/etc/nixos/dotfiles#$HOSTNAME"
-
Reboot
reboot
-
Log in as
root
with the password set in the NixOS installation -
Open a terminal and set password for my user
passwd dany
-
Log out
logout
-
Log in as my user
-
Setup 1Password, my password manager. The settings for the CLI, desktop and browser extensions are explained in one of the secure notes.
-
Clone the dotfiles repository
git clone [email protected]:dmarcoux/dotfiles.git ~/dotfiles
-
Setup
secrets
gitsubmodulecd ~/dotfiles && git submodule init && git submodule update && cd secrets && echo "Follow instructions from the Setup section in secrets' README"
-
Copy over the files from
/etc/nixos/dotfiles
to the dotfiles repository. -
Commit and push the changes to the dotfiles repository.
-
Build the NixOS system for the host. Its hostname matches one of the directories under hosts/.
sudo nixos-rebuild boot --flake /home/dany/dotfiles
-
Reboot
reboot