dot

vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks

200 lines9663 bytesMarkdown

Moving from CachyOS to NixOS

The install wipes the whole NVMe drive (nvme0n1, the 980 PRO) and lays it out again with disko, as hosts/desktop/disko.nix describes. CachyOS and everything in it are gone afterwards, so your home folder goes to the Kingston SATA SSD (sda) first and comes back after the install. Game installs aren't backed up (see backup-filter): Steam games and WoW download again. WoW's settings and addons are kept.

The other SATA SSD (sdb) isn't touched at any point. disko only knows the NVMe drive, by its serial number.

1. Before you start (on CachyOS)

The backup can be made ahead of time, days before the install if you like. Right before the wipe you run the two rsync commands below again (and the "save the built system" step, if the config changed since); they only copy what changed, so that takes a minute or two.

tools/backup-to-sata does all of the steps below in one go (run it with sudo; it only formats the Kingston if it is empty). They are spelled out here too, in case you'd rather do them by hand.

Prepare the backup drive (once). This erases sda, the 112 GB Kingston, which is empty now. Check that the name points at sda first:

ls -l /dev/disk/by-id/ata-KINGSTON_SA400S37120G_50026B76820FD3CE
sudo mkfs.btrfs -L backup /dev/disk/by-id/ata-KINGSTON_SA400S37120G_50026B76820FD3CE
sudo mkdir -p /mnt/backup
sudo mount -o compress=zstd /dev/disk/by-label/backup /mnt/backup
sudo install -d -o vizie /mnt/backup/nix-cache /mnt/backup/wow

Save the built system. The finished system and the disko script go onto the backup drive, so the installer doesn't have to build anything (or compile the CachyOS kernel, if its binary cache is still down):

cd ~/git/dot
sys=$(nix build --no-link --print-out-paths .#nixosConfigurations.desktop.config.system.build.toplevel)
disko=$(nix build --no-link --print-out-paths .#nixosConfigurations.desktop.config.system.build.diskoScript)
nix copy --to 'file:///mnt/backup/nix-cache?compression=zstd' "$sys" "$disko"
echo "$sys" > /mnt/backup/nix-cache/system
echo "$disko" > /mnt/backup/nix-cache/disko

Back up WoW's settings and addons (WTF is keybinds, macros and addon settings, Interface is the addons):

rsync -a --delete ~/Games/battlenet/drive_c/'Program Files (x86)'/'World of Warcraft'/_retail_/{WTF,Interface} /mnt/backup/wow/

Back up your home folder. Quit Signal, Discord, Firefox, Claude and the games first, so their databases aren't copied halfway through a write. About 83 GB before compression, and the saved system adds roughly 10 GB, so it fits the 112 GB drive with some room. If it runs out of space, leave out repos that are pushed to GitHub (the biggest are git/skate3, 23 GB, and git/philly, 16 GB) with an extra --exclude=/git/skate3/:

sudo rsync -aHAXx --delete --info=progress2 --filter='merge /home/vizie/git/dot/backup-filter' /home/vizie/ /mnt/backup/vizie/

Check that it looks complete (ls -a /mnt/backup/vizie, du -sh /mnt/backup/*), then sudo umount /mnt/backup. To update the backup later, mount it again (sudo mount -o compress=zstd /dev/disk/by-label/backup /mnt/backup) and rerun the commands above.

2. Install

Boot the installer. Wired network works out of the box; the install itself doesn't need it.

sudo -i

# The backup drive, read-only. Not under /mnt: disko unmounts everything there.
mkdir /backup
mount -o ro /dev/disk/by-label/backup /backup
sys=$(cat /backup/nix-cache/system)
disko=$(cat /backup/nix-cache/disko)

# The disko script. It doesn't ask before it wipes, so check that the drive it
# names is the 980 PRO (nvme0n1) one last time.
ls -l /dev/disk/by-id/nvme-Samsung_SSD_980_PRO_1TB_S5GXNF1R877751D
nix --extra-experimental-features nix-command copy --no-check-sigs --from file:///backup/nix-cache "$disko"

# Wipe, partition, format and mount the NVMe drive at /mnt.
"$disko"

# Copy the system onto it and install it, with the boot loader.
nix --extra-experimental-features nix-command copy --no-check-sigs \
  --from file:///backup/nix-cache --to 'local?root=/mnt' "$sys"
nixos-install --system "$sys" --no-channel-copy
# It asks for a root password at the end.

# What you chose to keep of your home folder (restore-filter), owned by you
# (uid 1000, group users). The rest stays on the backup drive.
rsync -aHAX --info=progress2 --chown=1000:100 \
  --filter='merge /backup/vizie/git/dot/restore-filter' /backup/vizie/ /mnt/home/vizie/
nixos-enter --root /mnt -c 'passwd vizie'
reboot

If something in /backup/nix-cache is missing, install from the flake instead (this needs the network, and compiles the kernel if its cache is down): nixos-install --flake /backup/vizie/git/dot#desktop after nix run github:nix-community/disko/latest -- --mode destroy,format,mount /backup/vizie/git/dot/hosts/desktop/disko.nix.

3. First boot

4. What changed

What is different from CachyOS, all on purpose:

Unchanged on purpose, but worth knowing:

5. Games

6. Once you're happy

The backup on sda stays until you need the drive for something else. It is the only copy of what wasn't restored, including the repos that exist only here (skate3, skate-game, he60, move, and Left4Resi's uncommitted changes), so copy out anything you want before reusing the drive. NixOS doesn't mount it; sudo mount /dev/disk/by-label/backup /mnt gets you into it.