Day 11 — Install NixOS lab
Day 11 — Install NixOS lab
Stage II · ~4h (hands-on heavy)
Goal: Install a disposable NixOS 26.05 “Yarara” lab system (VM strongly preferred), boot it, capture hardware config notes, and prepare for flake-based management tomorrow.
Do not experiment on your only daily-driver disk. Use a VM, spare machine, or spare disk. Reinstall without drama is a feature.
Why this day exists
Generations, rollback, modules, and firewall only become real on a host. Stage I was the package manager + language. Stage II is owning a machine as code—starting with a clean install.
Theory 1 — What you are installing
| Piece | Role |
|---|---|
| NixOS | Linux distribution built from Nix modules |
| nixpkgs 26.05 “Yarara” | Package + module set baseline for this volume |
| Installer image | Live environment to partition + install |
| First generation | Initial system closure after install |
After install you have a bootable system. Flake ownership is Day 12—today can use installer defaults, but mentally prepare to migrate immediately.
Theory 2 — Disposable VM emphasis
| Host choice | Recommendation |
|---|---|
| VM (QEMU/KVM, UTM, VirtualBox, VMware, …) | Preferred |
| Spare laptop/NUC | Good |
| Dual-boot daily driver | Risky for learning |
| Cloud VM | Fine if you accept networking/SSH from the start |
VM resources (practical)
| Resource | Starting point |
|---|---|
| RAM | 4–8 GB |
| Disk | 40–64 GB+ |
| CPU | 2+ cores |
| Firmware | UEFI if available |
| Snapshot | Take one after first successful boot |
Snapshots turn “I broke GRUB” into “restore 30 seconds.”
Theory 3 — UEFI vs legacy BIOS
| Mode | Common loader on NixOS |
|---|---|
| UEFI | systemd-boot (often default) or GRUB EFI |
| BIOS/CSM | GRUB |
Prefer UEFI for new labs. Note which you used—Day 20 returns to boot loaders.
Theory 4 — Disk layout options
Manual (classic installer path)
- Partition (ESP + root, optional swap)
- Format
- Mount at
/mnt, ESP at/mnt/boot
nixos-generate-config --root /mnt
- Edit
configuration.nix
nixos-install
Disko (intro only)
Disko declares disks as code. Full Disko redesign is Stage VI (Day 57). Today:
- Know Disko exists
- Optionally follow a simple Disko example if you already know it
- Otherwise manual once is fine and educational
Do not block install on learning Disko deeply today.
Suggested simple layout (UEFI)
ESP (vfat) 512MB–1GB → /boot
root (ext4 or btrfs) → /
swap (optional)
Theory 5 — nixos-generate-config outputs
| File | Role |
|---|---|
hardware-configuration.nix |
Detected devices, fileSystems, initrd modules |
configuration.nix |
High-level system config (you own this) |
Rules of thumb
- Treat
hardware-configuration.nixas machine-specific; rarely hand-merge casually
- Put policy (users, services, packages) in
configuration.nix/ modules
- Tomorrow both get imported from a flake
Theory 6 — Installer networking and time
Install needs:
- Network for substitutes (unless offline media strategy)
- Correct clock helps TLS
# live environment examples (names vary)
ip a
ping -c 2 1.1.1.1Theory 7 — First boot mental model
After nixos-install and reboot:
bootloader → kernel+initrd → stage-1/2 → systemd → multi-user
system profile: /nix/var/nix/profiles/system
generation N is current
You can log in as root or the user you created. Prefer SSH key setup ASAP (Day 14 formalizes); avoid building habits around password-only remote root.
Theory 8 — Credentials hygiene on a lab
| Practice | Why |
|---|---|
| Unique lab password | Compromise isolation |
| Note in password manager | Labs still get attacked if exposed |
| Prefer host-only networking until ready | Reduce drive-by SSH noise |
| Snapshot before experiments | Fast recovery |
Worked examples bank
Example A — Download image
Use official docs for current ISO:
Pick 26.05 graphical or minimal ISO matching your arch (x86_64, aarch64).
Verify checksums when provided.
Example B — Partition sketch (sfdisk/parted-level ideas)
/dev/vda1 EFI System FAT32 /boot
/dev/vda2 Linux root ext4 /
Device names: vda (virtio), sda, nvme0n1—use what the live system sees (lsblk).
Example C — Generate + install skeleton
# after mounts ready
sudo nixos-generate-config --root /mnt
sudo nano /mnt/etc/nixos/configuration.nix
sudo nixos-install
# set root password when promptedExample D — Minimal configuration knobs to set during install
{
imports = [ ./hardware-configuration.nix ];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "lab";
time.timeZone = "UTC"; # set yours
users.users.alice = {
isNormalUser = true;
extraGroups = [ "wheel" ];
# initialPassword only for offline lab convenience — rotate later
initialPassword = "changeme";
};
services.openssh.enable = true; # if you want SSH into VM
system.stateVersion = "26.05"; # match release; do not casually change later
}Exact options must match your installer generation—adapt from generated file rather than blind paste.
Lab 1 — Plan and snapshot strategy
Write in ~/lab/90daysofx/02-nixos/day11/NOTES.md (on the host machine):
- Hypervisor / hardware choice
- UEFI or BIOS
- Disk size
- Hostname
- Username
- Networking mode (NAT/bridge)
- Snapshot plan
Lab 2 — Install NixOS 26.05
- Boot installer ISO
- Partition + format + mount
nixos-generate-config --root /mnt
- Edit config: hostname, user, boot loader, optional SSH
nixos-install
- Reboot into installed system
- Take a VM snapshot labeled
day11-fresh-install
If install fails, journal the error class (bootloader, mount, network, disk).
Lab 3 — Post-install inventory
On the new system:
nixos-version
uname -a
lsblk -f
cat /etc/os-release
ls /etc/nixos/Copy off-box (screenshot/scp) or retype into host NOTES.md:
nixos-versionoutput
- Disk layout
- Boot loader in use
- IP address if any
Lab 4 — Preserve hardware config
# on NixOS lab
sudo cp -a /etc/nixos /root/nixos-etc-backup-$(date +%F)On host lab notes, record that Day 12 will create a flake and import hardware-configuration.nix.
Optional: already enable flakes in system config for smoother Day 12:
nix.settings.experimental-features = [ "nix-command" "flakes" ];Then sudo nixos-rebuild switch once if you edit on the running system.
Lab 5 — Break-glass familiarity
Without destroying the snapshot casually:
- Locate boot menu / how to pick previous generation (may only have gen 1)
- Confirm you can log in on console
- If SSH enabled, log in from host once
Common gotchas
| Symptom | Theory |
|---|---|
| No bootable device | ESP not mounted at /mnt/boot or wrong firmware mode |
| Install can’t reach cache | Network/DNS in live env |
| Forgot root password | Live ISO recovery / reinstall—why snapshots matter |
hardware-configuration wrong root UUID |
Generated before final mounts |
| Using unstable ISO by mistake | Check 26.05 label |
| Daily driver install “for fun” | Restore from backup; prefer VM next time |
Checkpoint
- Disposable NixOS 26.05 lab boots
- User + privilege path known (root/wheel)
- Disk + boot mode documented
/etc/nixosinspected
- VM snapshot taken (if VM)
- Notes stored on host machine
Commit
# on host workstation notes repo
cd ~/lab/90daysofx/02-nixos/day11
git init 2>/dev/null || true
git add .
git commit -m "day11: nixos 26.05 lab install notes"Tomorrow
Day 12 — Flake host skeleton. Put the machine under nixosConfigurations and rebuild with nixos-rebuild switch --flake .#host—flakes from the first serious ownership moment.