In March I wrote about managing twelve machines with NixOS. When I read it again, I noticed that it starts somewhere in the middle: it assumes you already run NixOS, already have a flake, and already know what a module is. If you don’t, reading it is a bit like asking for directions and getting a photo of the destination.
And getting started really is the hard part. A graphical installer asks you a few questions and then hands you a desktop. The NixOS minimal ISO doesn’t ask you anything. You get a blinking cursor, a disk and a manual, and the rest is up to you. The manual is good and walks you through partitioning, but then it gives you a configuration.nix and nixos-install, and flakes, which is how I build everything these days, get a single sentence near the end.
So I want to walk you through one complete first installation, from that blinking cursor to a KDE desktop with a terminal, NetworkManager and git, built from a flake right from the first boot. You should be comfortable in a Linux shell; the NixOS part is what I’ll explain along the way. I did every step in a virtual machine, in the order you’ll read them, and the screenshots are from that run. One step tripped me up, and I left that in, right next to the way around it.
I did all of this on 10 November 2026 with the NixOS 26.05 minimal ISO. If you’re reading this a good while later, a few details will have moved on, but the steps should still get you there.

Where We’re Headed
This is where you’ll end up:

That’s KDE Plasma with Konsole open and the network icon down in the corner. It’s not a fancy desktop, and I didn’t want it to be. What I care about is what’s behind it. Whatever you set up through NixOS, whether it’s a program, a service or some system setting, ends up as a few lines of text in a git repository in your home folder. You can read those files, diff them and commit them, and when you change one and rebuild, the machine changes with it.
There’s plenty this post leaves alone, on purpose. The disk isn’t encrypted, you’ll partition it by hand rather than describe it with disko, your personal settings stay outside the flake for now (that’s what Home Manager is for), and it’s just the one machine. All of that is worth doing, and all of it gets a lot easier once you have a working system you can always come back to. A first day with NixOS has enough new things in it already.
“Can’t I just use the graphical installer?”
Sure, and there’s nothing wrong with that. The graphical ISO runs Calamares, you click through a few pages and you have a desktop, with a classic configuration.nix and no flake. That’s a perfectly good way to start. I went with the minimal ISO because I wanted the flake there from the very first boot, and because writing the configuration yourself means you know what each file is for. That pays off the first time something breaks and you actually recognise what you’re looking at.
Real hardware or a VM
Everything below works the same on a real computer and in a virtual machine. I did it in a VM, and if you’re unsure, that’s a good place for a first go: when something goes wrong, you throw the VM away and start over, and your real disk never finds out.
Any VM software will do, VirtualBox, virt-manager or plain QEMU from your distribution, as long as you check two settings before the first start:
- UEFI firmware. The boot loader in this post needs it, and many VM programs start with legacy BIOS unless you tell them otherwise. In VirtualBox it’s the Enable EFI checkbox; in virt-manager you tick Customize configuration before install and pick UEFI as the firmware.
- A SATA disk. Then the disk shows up as
/dev/sda, like in the manual and in every command below. With a virtio disk it’s/dev/vdainstead, with partitionsvda1,vda2and so on.
Mine had 6 GB of RAM and a 40 GB disk.
Either way, download the Minimal ISO image from nixos.org/download. In a VM, it goes into the virtual CD drive. For a real computer, write it to a USB stick as the manual describes.
Boot the Installer and Get a Root Shell
One thing before you boot it: turn off Secure Boot in the firmware settings. The NixOS ISO isn’t signed for it, and neither is the boot loader you’re about to install. In a VM that offers a choice of UEFI firmware, pick the one without Secure Boot.
The ISO boots into a menu, and the first entry is the one you want.

A few seconds later you’re on a plain text console, already logged in as a user called nixos, and nobody asked you for a password. Grab a root shell and see what you’re working with:
In the installer, from here on as root:
sudo -i
ip -br a
lsblk

If there’s a network cable plugged in, you’re already online. On WiFi, nmtui gives you a small menu where you pick your network. And on a real computer your disk may well be /dev/nvme0n1 rather than /dev/sda, with partitions called nvme0n1p1, nvme0n1p2 and so on, so check lsblk before you type anything that formats.
Partition, Format, Mount: Straight from the Manual
I didn’t want to get creative with the disk, so this is the manual’s example, unchanged, and you can always hold the two side by side.
This wipes the whole disk. On a real computer, check with lsblk that /dev/sda really is the disk you want to give to NixOS, and if yours has another name, change it in every line below.
parted /dev/sda -- mklabel gpt
parted /dev/sda -- mkpart root ext4 512MB -8GB
parted /dev/sda -- mkpart swap linux-swap -8GB 100%
parted /dev/sda -- mkpart ESP fat32 1MB 512MB
parted /dev/sda -- set 3 esp on
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mkfs.fat -F 32 -n boot /dev/sda3
mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount -o umask=077 /dev/disk/by-label/boot /mnt/boot
swapon /dev/sda2
That leaves you with a large partition for the system, 8 GB of swap at the end and a small boot partition at the front. parted keeps telling you “You may need to update /etc/fstab”, and you can ignore it, because NixOS writes that file for you. The umask=077 keeps the boot partition private to root, which the boot loader insists on.
Let NixOS Look at the Hardware
nixos-generate-config --root /mnt
This has a good look at the machine and writes two files into /mnt/etc/nixos/. The one you’ll keep is hardware-configuration.nix.
Example output from my VM. Keep the file generated on your machine, and don’t copy these UUIDs:
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" "sr_mod" ];
boot.kernelModules = [ "kvm-intel" ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/7c0cec0c-2f31-462f-831f-09fdc2898668";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/EF68-9843";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
swapDevices =
[ { device = "/dev/disk/by-uuid/6bdfc13e-aa78-4394-9ef5-8c99c5b55c1c"; }
];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}
It figured out that it’s running inside QEMU, found the partitions you just mounted, and worked out which drivers the early boot stage needs to get to the disk. This is also where your fstab ends up. You don’t edit it by hand; it belongs to this disk in this machine.
The second file is configuration.nix. It’s about a hundred lines, nearly all of them commented-out examples, and it’s worth reading once because it’s a nice little tour of what NixOS can do. After that, delete it:
rm /mnt/etc/nixos/configuration.nix
With a flake, nothing reads that file anymore, and a configuration.nix that does nothing is a trap. Sooner or later you’d edit it and wonder why nothing changes.
About the --flake switch
nixos-generate-config --flake can write a flake.nix for you too, but the one it wrote for me follows nixos-unstable, the rolling release. Nothing wrong with unstable, my own machines run it. But you just booted a 26.05 installer, and you shouldn’t end up on a different release without noticing. The flake is only about a dozen lines anyway, so let’s write it ourselves.
The Smallest Flake That Installs
This is the part the manual leaves out. You need two files in /mnt/etc/nixos/, and the ISO has nano and vim to write them with. Start with flake.nix:
{
description = "My first NixOS machine";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
};
outputs = { nixpkgs, ... }: {
nixosConfigurations.wonderland = nixpkgs.lib.nixosSystem {
modules = [
./hardware-configuration.nix
./base.nix
];
};
};
}
A flake has inputs and outputs, and this one has one of each. The input is nixpkgs on its nixos-26.05 branch, which only moves forward once a new build has passed the NixOS tests. It gives you all the packages and, along with them, the whole NixOS module system. The output is a NixOS configuration called wonderland, which nixosSystem builds from the modules in that list: the hardware file the installer generated, and base.nix, which you’ll write next. Every file you write for this system goes into that list. Modules can also pull in other files through imports, the way the hardware file above pulls in qemu-guest.nix, but for your own files the list is where it starts, so whenever you wonder what your system is made of, flake.nix is the place to look.
Call it whatever you like. The user is alice, so I went with wonderland. Just give the machine the same hostname in base.nix below, because nixos-rebuild looks for the configuration named after the machine it runs on, and then you never have to type it.
Next comes base.nix, with the settings that make this machine yours:
{ config, pkgs, ... }:
{
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "wonderland";
networking.networkmanager.enable = true;
time.timeZone = "Europe/Berlin";
users.users.alice = {
isNormalUser = true;
extraGroups = [ "wheel" "networkmanager" ];
};
nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = with pkgs; [
git
vim
];
system.stateVersion = "26.05";
}
Put your own user name in place of alice and your own time zone instead of Berlin. Here’s what each part does:
- Boot loader: systemd-boot, and the permission to add itself to your firmware’s boot menu.
- Hostname and NetworkManager: the same NetworkManager the installer uses, so the network works the same way once you’re on the installed system.
- Your user:
wheelis what lets you usesudo, andnetworkmanagerlets you change network settings. - Flakes: they’re still officially marked experimental, so you have to tell the installed system that you use them.
nixos-installandnixos-rebuildquietly turn them on for themselves, so if you forget this line, you won’t notice until the day you runnix flake updateand Nix refuses. - Packages:
environment.systemPackagesis simply the list of programs you want installed. Everything else on the system is there because some module needed it. system.stateVersion: it’s tempting to read this as the release you’re on, but it isn’t. It remembers which release this machine was installed with, so that services keeping data on disk, databases for example, stay with the formats they started out with. You set it now and leave it as it is, even when you upgrade later.
Lock First, Then Install
Here the manual would have you run nixos-install, and that’s exactly what I did the first time. It failed (more on that in a moment), so now I run one more command before it, which writes the lock file first:
nix --extra-experimental-features "nix-command flakes" flake lock /mnt/etc/nixos
nixos-install --flake /mnt/etc/nixos#wonderland
The lock file, flake.lock, records exactly which nixpkgs you’re on. The nixos-26.05 branch moves forward with every new build, while the lock file keeps your configuration on the one you have until you decide to update.
With the lock file there, the install was done in under a minute on my connection. It only asks you one thing, right at the end: a root password. You’ll hardly ever need it, but on a bad day it’s how you get in.
Why I create the lock file myself
When I ran nixos-install on its own, on a fresh folder without a lock file, it gave up with this:
warning: creating lock file "/mnt/etc/nixos/flake.lock":
copying channel...
building the flake in path:/mnt/etc/nixos?lastModified=1794334496&narHash=sha256-%2BZnS3...
error: NAR hash mismatch in input 'path:/mnt/etc/nixos?lastModified=...', expected 'sha256-53a6Pfki...' but got 'sha256-+ZnS3Zmj...'
A hash mismatch, in a folder you made five minutes ago, on the very first NixOS command you run. If you get this, you didn’t do anything wrong. The installer script starts by running nix flake metadata on your folder. That takes a fingerprint of what’s in it and, while it’s at it, writes flake.lock into the same folder. Then the script builds against the fingerprint, finds a file that wasn’t there when the fingerprint was taken, and refuses to go on. It basically trips over its own lock file.
Other versions of the ISO might not do this at all. If it does happen to you, just run the install again, because by then the lock file is there. I’d rather create it up front and never see the error.
nixos-enter: One Last Thing Before the Reboot
There’s one thing the flake can’t do for you, and that’s setting a password. The alice account exists on the new system, but it doesn’t have a password yet, so you couldn’t log in. nixos-enter lets you fix that from the installer. It runs a command inside the freshly installed system, a bit like chroot, but it also sets up what NixOS’s own tools expect to find:
nixos-enter --root /mnt -c 'passwd alice'
Keep nixos-enter in mind, by the way. If a system ever refuses to boot, you can start the ISO, mount the disks to /mnt like you did today, and nixos-enter gets you a working shell inside it.
You’ll notice the password doesn’t end up in any of your .nix files. Like your personal files, it lives on the machine and not in the configuration.
In the VM, shut down rather than reboot, so you can start it again without the ISO:
poweroff
Then take the ISO out of the VM’s virtual CD drive and start the VM again. On real hardware, reboot and pull out the USB stick.
First Boot: Make the Config Yours
Now the system you wrote down boots for the first time. There’s just one entry in the boot menu, and after a moment you’re at a text login, where your user name and the password you just set get you in.
On your new system, as yourself, from here on:
If you used WiFi in the installer and the new system is offline, run nmtui once more. The installed system doesn’t know your WiFi password yet.
Your configuration is still in /etc/nixos, owned by root. I keep mine in a git repository in my home folder, and I’d move it there right away:
cp -r /etc/nixos ~/nixos
cd ~/nixos
git config --global user.name "Alice"
git config --global user.email "alice@example.org"
git init
git add .
git commit -m "Fresh install"
That way you can edit your configuration without sudo, every change has a history, and when something stops working, git log shows you what you changed right before. There’s another reason too, and you’ll run into it in a minute.
From here on, ~/nixos is your configuration. You can delete the old /etc/nixos once you’re comfortable with the new place.
Adding KDE: Two Lines and a Rebuild
I like to give the desktop a file of its own. You can see at a glance what KDE brought in, and if you ever want it gone, it’s one line in flake.nix. Create ~/nixos/desktop.nix:
{ pkgs, ... }:
{
services.displayManager.sddm.enable = true;
services.desktopManager.plasma6.enable = true;
programs.firefox.enable = true;
}
and add it to the module list in flake.nix:
modules = [
./hardware-configuration.nix
./base.nix
./desktop.nix
];
Those two options bring in more than their names suggest. You get the SDDM login screen on Wayland, PipeWire for sound (PulseAudio programs work too), Konsole, and because NetworkManager is on, a network icon in the panel. Firefox is my own addition.
Let git know about the new file, then build:
git add desktop.nix
nixos-rebuild boot --flake ~/nixos --sudo
--flake ~/nixos builds from your folder and picks the configuration named after the machine. --sudo lets you build as your normal user and only asks for your password when the result gets activated. And boot makes the new system the default from the next boot on, while leaving the one you’re running alone. For something as big as a whole desktop, that’s what I want. For everyday changes later on, switch activates the new configuration straight away.
Why the git add comes first
This is the other reason for the git repository. When your flake lives in a git repository, Nix only sees the files git knows about. If you skip the git add, the rebuild stops with this:
error: Path 'desktop.nix' in the repository "/home/alice/nixos" is not tracked by Git.
To make it visible to Nix, run:
git -C "/home/alice/nixos" add "desktop.nix"
You need an add here, not a commit. Once git knows about a file, Nix picks up your uncommitted edits to it as well. And the error message already tells you what to type.
The second boot
Be patient with this one. It’s the big download of the day, KDE and Firefox and everything they pull in, and in my VM it took far longer than anything else in this post. When it’s done:
reboot

The boot menu now has two entries. Generation 2 on top is your configuration with KDE, and it’s the default. Generation 1 below it is the console-only system you installed earlier, still there and exactly as it was. If the desktop doesn’t come up, pick Generation 1 and you’re back on the system you had before.
This time you’re greeted by the SDDM login screen instead of a text prompt. Log in, open Konsole, and you’re looking at the screenshot from the top of this post. I’d commit right now, while you know it works:
cd ~/nixos
git commit -am "KDE Plasma desktop"
The Loop from Here On
Your ~/nixos folder now has five files in it:
| File | What it does |
|---|---|
flake.nix | Picks the nixpkgs release, names your system wonderland and lists its modules |
flake.lock | Pins the exact nixpkgs build you’re using |
base.nix | Your main settings: boot loader, network, user, packages |
hardware-configuration.nix | What the installer found on this machine and disk |
desktop.nix | KDE and Firefox |
It helps to know what’s not in there, too. The passwords you set with passwd, the name you gave git config, and everything in your home folder live on the machine, the way they would on any other Linux. The folder describes the system, but your data isn’t in it.
From now on, changing your system always goes the same way:
- Change something in
~/nixos. git addwhat you changed, new files and edited ones.nixos-rebuild switch --flake ~/nixos --sudo- Check that it does what you wanted, then
git commit.
If you want a program, add it to environment.systemPackages. If you’re looking for a setting, bookmark search.nixos.org/options and search for things like “bluetooth” or “printing”. Every option from this post is in there, too.
Updating is two commands inside ~/nixos: nix flake update moves your lock file to the newest 26.05 build, and a rebuild applies it. Then commit the new flake.lock like any other change.
If an update or a change breaks something, nixos-rebuild switch --rollback --sudo takes you back to the previous system, or you pick an older entry in the boot menu. Keep in mind that a rollback only changes which system is running. Your ~/nixos folder and your files stay as they are, so after rolling back, fix or revert the change in the folder as well, or the next rebuild will cheerfully build the same problem again. And a rollback only swaps programs and settings. Data that a newer version has already converted, a database for example, stays converted.
When 26.11 comes out, change 26.05 to 26.11 in flake.nix, run nix flake update and rebuild. system.stateVersion stays at 26.05, even then.
When Something Goes Wrong
Sooner or later you’ll forget a git add. Nix tells you which file it can’t see, you add it, and you carry on.
A typo in a .nix file gives you an error that starts somewhere deep inside nixpkgs, and it’s a long, very serious-looking wall of text. Scroll to the bottom. The last few lines usually point at your file and the line where it went wrong, and quite often it turns out to be a missing semicolon.
Once you want to understand the files you wrote rather than just copy them, a good place to start is the { config, pkgs, ... }: at the top of base.nix. It means the file is a function: it gets its arguments and returns a set of options. The Nix language tutorial on nix.dev explains exactly this, with small examples you can try out in nix repl.
Where to Go Next
You now have a desktop, a terminal, a browser, and a small repository that describes how your system is put together. Here’s what I’d do next:
- Put
~/nixossomewhere other than this machine. GitHub, Codeberg or your own server all work. A reinstall then means partitioning and mounting the new disk, cloning the repository to/mnt/etc/nixos, generating a fresh hardware file for the new disk withnixos-generate-config --root /mnt --show-hardware-config > /mnt/etc/nixos/hardware-configuration.nix, and installing from the flake. Your passwords and personal files still need their own setup and backups. - Home Manager does for your own settings what this flake does for the system, so your shell and editor setup can live in files as well.
- A second machine. Add another entry next to
nixosConfigurations.wonderland, share what the two have in common, and you’re well on the way the twelve-machine post describes.
I came to NixOS from Gentoo and Debian. On Gentoo, the system on my disk was the result of months of commands I’d typed, and whatever notes I kept about them stopped matching reality pretty quickly. What you have now is a desktop with a record. The steps that got you here are in a few files and two commits, not scattered through your shell history. Push that repository somewhere safe, then add a program you actually use, rebuild, and commit it.