TheFocus.AI TheFocus.AI
Course

Building Autonomous Coding Agents with Nix

Build a reproducible agent lab on your Mac, move it to disposable Linux, and make tests govern every change. Nix, devenv, bounded Ralph loops, CI, and NixOS VM tests.

TUTOR WITH THEFOCUS.AI

Agent Integration

Copy this prompt into Claude, ChatGPT, or any external AI assistant. It points the assistant to the course instructions and links it to your student profile to track your progress and customize observations.

Please tutor me in this lesson using the following context. First, read the instructions at: https://courses.thefocus.ai/llms.txt My Student ID is: <none> The lesson markdown source is at: https://courses.thefocus.ai/nix-agent-lab/index.md

You are not enrolled yet. Enroll to generate a Student ID to track lesson completions and store learning notes.

Building Autonomous Coding Agents with Nix

4 parts · 12 chapters · MacBook first, Linux for unattended work

You can give an agent a clear task and still lose hours to missing tools, drifting dependencies, weak tests, and accidental access to the rest of your machine. This course builds the environment and verification loop around the agent, one observable contract at a time.

The result is a small task-board project with locked development dependencies, a PostgreSQL integration check, a precise completion feature, and a bounded agent controller. You prove the same reviewed commit on Mac and Linux, then test a Linux service across two NixOS machines.

What You’ll Build

  • A Nix/devenv environment with explicit dependencies and a committed lock.
  • Unit, formatting, lint, and database checks behind devenv test.
  • AGENTS.md, a behavior spec, an implementation plan, and a focused prompt.
  • A supervised agent change and a finite Ralph-style loop with time, turn, and cost controls.
  • A disposable Linux worker whose credentials and lifetime are limited outside the agent.
  • A Mac/Linux CI matrix and a two-node NixOS VM test with a deliberate red/green experiment.

The Spine

locked tools → tested behavior → real service → precise spec
    → supervised agent → bounded worker → cloud parity → system tests

Tests supply evidence, not omniscience. Nix supplies reproducible dependency definitions, not agent isolation. The course makes those distinctions practical rather than hiding them behind an “autonomous” label.

Course Structure

PartChaptersWhat you prove
Reproducible Foundations01–03The declared tools work and the verifier catches a defect
Services and Contracts04–06The database check is repeatable and the next feature has testable acceptance
Controlled Agents07–09A reviewed change, finite retry behavior, and an actual worker boundary
Cloud and System Tests10–12The same source/lock passes supported hosts and a network test catches a firewall defect

What You Need

Comfort with a terminal, Git branches, and reading a small Python function. No prior Nix or NixOS experience is required. You need permission to install Nix on your Mac, disk space for dependency downloads, and network access to upstream package sources.

Parts 1–2 require no model spend. Part 3 uses a coding-agent account; the scripted example uses a scoped Anthropic API key. Part 4 needs a disposable Linux machine or an existing suitable runner. The final VM lab targets x86 Linux with KVM. Do not buy cloud resources until you understand the architecture and teardown gates. Learners without cloud access can finish the local work and clearly mark the cloud gates incomplete.

Plan roughly 12–20 focused hours across several sessions, plus downloads and debugging. This is an estimate, not a promised completion time.

Download the Lab

Download the complete starter lab. Read its README before running anything. The baseline application works; the task-completion enhancement is intentionally absent. Acceptance tests for that enhancement are enabled in Chapter 06.

The starter is a bootstrap, not a claim of a pre-frozen environment. Chapter 02 generates and commits your actual devenv.lock; Chapter 07 records an agent package revision; Chapter 12 creates the NixOS flake lock. Later clones use those exact files. Never invent lock hashes or substitute a moving branch silently.

How Tutoring Works Here

Use the site’s tutor prompt on each lesson. Explain the mechanism first, answer the concept check, and show the result at each gate. The answer key is a grading aid; attempt the questions before opening it. Every lesson closes with a check of understanding and pass criteria.

Inspiration and Currency

Inspired by Geoffrey Huntley’s Nix/devenv discussion and Ralph loop. This course adds its own toy application, exercises, bounded controller, and validation gates. It is not affiliated with or endorsed by Huntley.

Technical references were reviewed on October 12, 2026. CLI flags, installers, packages, and hosted runners evolve. Each installation gate verifies the installed tool before relying on it. A finished site build is not proof that every learner’s cloud or Nix environment has been executed; the course requires evidence at those gates.

Start: Chapter 01 → · About and references

01 reproducible foundations

02 services and contracts

03 controlled agents

04 cloud and system tests