Installing NixOS on my desktop
Terminology
A few terms I'll probably use, for context and so you know what I'm talking about when I say them.
- Lys : My desktop's name, but also my name. In this article, it will refer only to my desktop.
- Azyari : My laptop's name
Context
So, a week or so ago I noticed that I was running low on space, that my package numbers were suspiciously high, and in general that my system's getting quite bloated. I've been using Arch Linux for a while now, and I've been quite happy with it, but I've got some issues with it. Meanwhile, on Azyari , I've been using NixOS and it's quite good. A couple of times I've had issues, but I've figured them out pretty quickly.
I'd been thinking about switching to NixOS on Lys as well, but of course that's quite an undertaking. First off, I've got a lot of games, software, and other things I commonly use installed. Thankfully, a good portion of my system is already configured through Nix and home-manager. The main issueful programs are Alacritty/Zed/Neovide/VSCode; GUI programs that need the right drivers, and Nix doesn't quite like loading my system drivers (for reasons I think I understand). Yet they run fine on Azyari .
Having bought a new SSD and with it hopefully arriving today, I'll be able to get started the moment I shove it in behind the GPU I have to pull out. Just a Samsung 970 Evo Plus, 1TB or so.
Plan
There is a plan. Somehow. I've been running various backups using a hacked-together script I've
called The code is available in a gist which just uses rsync and b3sum with some hackery, and so far it's been good :3
0. Prep
I've already made a custom NixOS minimal iso for this, with my laptop's SSH keys as well as a pre-configured neovim setup so I can edit files in style.
1. Partition the new drive as a single massive partition
Probably using btrfs with compression, just so I can definitely fit everything in there. My Steam and non-Steam games in total are around 900GiB or so. With compression,
that should fit there neatly, so I can move on to...
2. Format and partition the old drive
The plan is for my current drive (1.8TiB) to be split in two, one partition for Steam and one for
non-Steam. This way I'll have a bit more control over what's where, and I can keep my games
separate from my system. I'll still be using btrfs with compression, with subvolumes.
For partitioning, I'm going to be figuring out how to use disko, since I plan to use it for my NixOS install partitioning and configuration as well. Once that's done, everything that I moved to my new drive will get shuffled back to the old one, so that I can...
3. Install NixOS
I plan to use KDE/Plasma, since I already use it and I like it. It works for me and I doubt that'll change. The main issue is I'll need to move my NixOS config into user folders, since I want to keep it in my code forge. But I've already found info on how to do that, so it should be fine.
For user-environment configuration, obviously I'll be using home-manager, and maybe even plasma-manager, if I can get it to work properly.
The user environment and OS configuration will be in separate repos. My user environment configs are already in a repo shared between machines, which makes updating/management nice and easy. But the OS stuff feels like it should be separate, so I'll be doing that.
4. ???
Reinstalling everything I need/use/want is gonna be "fun", but hopefully it'll work out. We'll see once I get around to actually doing it.
Doing It
1. Moving things across
Thankfully, with the power of btrfs and compress=zstd:8 , everything I needed to move fits nicely onto the new drive. Got to go through and delete some junk
as well which helped.
2. Partitioning the old drive
This is gonna be a "fun" one. I'm planning on going with a 45/35/20 split. 45% for Steam, 35% for non-Steam, and 20% for anything else more "persistent" that I wanna have
across systems. This comes out to... roughly... whatever I put in the table below. These are probably
gonna be using ZFS instead of btrfs , since... the latter's qgroup support is still unstable according to docs.
ZFS also natively supports setting limits on dataset sizes, which is nice.
| Dataset | Size % | ~Size (GiB) |
|---|---|---|
| Steam | 45% | 810 |
| Non-Steam | 35% | 630 |
| Other | 20% | 360 |
The preliminary Disko config is thus the following, hopefully with code highlighting. I don't actually know what my site supports fully :3
old_disk.nix
{
disko.devices = {
disk = {
games = {
device = "/dev/nvme0n1";
type = "disk";
content = {
type = "gpt";
partitions.data = {
size = "100%";
content = {
type = "zfs";
pool = "zdata";
};
};
};
};
};
zpool = {
zdata = {
type = "zpool";
rootFsOptions = {
compression = "zstd";
"com.sun:auto-snapshot" = "false";
};
postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zdata@blank$' || zfs snapshot zdata@blank";
datasets = {
steam = {
type = "zfs_fs";
options = {
quota = "810G";
compression = "zstd-4";
mountpoint = "legacy";
};
};
games = {
type = "zfs_fs";
options = {
quota = "630G";
compression = "zstd-4";
mountpoint = "legacy";
};
};
excess = {
type = "zfs_fs";
options = {
quota = "360G";
reservation = "60G";
compression = "zstd-8";
mountpoint = "legacy";
};
};
};
};
};
};
}
Getting this config right took a while of experimentation. I got things wrong a few times, but the current version is fine and data is moving to it quickly. Once the data's all there, I can move on to preparing the NixOS install.
3. Preparing the NixOS install
Since I'm gonna be using disko-install to install the new drive. I will be importing my old disk afterwards, rather than configuring it upfront.
I wouldn't want to accidentally override any data on it, after all. Anyways there's a lot to configure
so this is gonna be a bit of a pain.
A lot of a pain.
>Some time later... several hours in fact...
I think I've gotten it building now. Just a dry-run for now, just to make sure nothing... borks. But I think I've gotten a basic configuration set up so that I can easily start working on my desktop from my desktop. All nicely in a private git repo, of course, so that I can import it over to Lys when I'm ready.
Another hour later...
I had the excellent idea to move over to using zfs as my root filesystem instead. It should make backing up to my server a breeze, since that also uses zfs . Time to reformat the new drive :3
The install has begun. I'm anxious, it's scary, but I hope it works. It should work. Nothing was failing, no... obvious errors. But... You never know.
4. ???
I'm not sure what's next. I guess I'll just have to wait and see. I'm sure I'll figure it out eventually.