dot

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

127 lines5929 bytesMarkdown

Moving from CachyOS to NixOS

The plan keeps your disk as it is. NixOS goes into new btrfs subvolumes next to CachyOS's, and /home stays the same @home subvolume. Your files, game libraries, app data, ~/.ssh, Firefox profile and Steam settings never move, and CachyOS stays bootable until you remove it.

1. Before you start

2. Install

Boot the installer. Wired network works out of the box.

sudo -i

# The btrfs partition's top level, to make NixOS's subvolumes.
mkdir -p /mnt/top
mount -o subvolid=5 /dev/nvme0n1p2 /mnt/top
btrfs subvolume create /mnt/top/@nixos
btrfs subvolume create /mnt/top/@nix
btrfs subvolume create /mnt/top/@nixos-log
umount /mnt/top

# Mount the new system the way hosts/desktop/hardware-configuration.nix does.
o=noatime,compress=zstd
mount -o subvol=@nixos,$o /dev/nvme0n1p2 /mnt
mkdir -p /mnt/{nix,var/log,home,boot}
mount -o subvol=@nix,$o /dev/nvme0n1p2 /mnt/nix
mount -o subvol=@nixos-log,$o /dev/nvme0n1p2 /mnt/var/log
mount -o subvol=@home,$o /dev/nvme0n1p2 /mnt/home
mount /dev/nvme0n1p1 /mnt/boot

# Compare the generated hardware config with the one in the repo; if the
# kernel modules or anything else differ, keep the generated lines.
nixos-generate-config --root /mnt --show-hardware-config > /tmp/hw.nix
diff /tmp/hw.nix /mnt/home/vizie/git/dot/hosts/desktop/hardware-configuration.nix

# philly is a private repo: sign in to GitHub for this root shell.
nix --extra-experimental-features 'nix-command flakes' shell nixpkgs#gh -c gh auth login
git config --global credential.helper '!gh auth git-credential'

# Install. The extra cache is where the CachyOS kernel comes from.
nixos-install --flake /mnt/home/vizie/git/dot#desktop \
  --option extra-substituters https://attic.xuyh0120.win/lantian \
  --option extra-trusted-public-keys lantian:EeAUQ+W+6r7EtwnmYjeVwx5kOGEBpjlBfPlzGlTNvHc=

# It asks for a root password at the end. Then set yours:
nixos-enter --root /mnt -c 'passwd vizie'
reboot

The NixOS boot menu (systemd-boot) becomes the default. CachyOS's Limine stays in the firmware boot menu (F8 at the ASUS logo), and also on the ESP, next to it.

3. First boot

4. What changed

What is different from CachyOS, all on purpose:

Unchanged on purpose, but worth knowing:

5. Going back to CachyOS

It still boots (firmware boot menu). Its ~/.config links now point into NixOS's store, which CachyOS doesn't have, so rerun the old repo's script there: ~/git/dotfiles/symlink.sh.

6. Once you're happy

Remove CachyOS: boot NixOS, mount the top level, delete its subvolumes (@, @root, @srv, @cache, @tmp, @log), then its kernels and Limine files from the ESP (look first: sudo ls -R /boot; NixOS's own files are /boot/EFI/nixos, /boot/EFI/systemd, /boot/EFI/BOOT and /boot/loader), and its firmware boot entry (efibootmgr).