Persistent NixOS Cloud VMs: Reproducible Machines for Agents and Teams
A NixOS VM on machine0 is a machine whose entire configuration is code. You write a flake, apply it to a VM or build it into an image, and every clone boots identical. Nothing drifts, rollbacks are one command, and an agent can author and verify the configuration the same way it writes any other code. This guide covers the images, the three ways to build a machine from a flake, snapshots, GPUs and cost.
## Why NixOS for cloud machines
On most cloud VMs the operating system is whatever the last person did to it. Packages get installed by hand, config files get edited, and a second machine that is supposed to match the first never quite does. NixOS replaces that with a declaration: a flake that names every package, service and setting. Building the flake produces the same system every time, switching to a new build is atomic, and the previous build stays available for a one-command rollback.
For agents this matters twice over. An agent can read and edit a flake like any other file, so it can add Postgres to a machine by changing a line rather than by running a dozen commands whose side effects nobody recorded. And a machine built from a flake can be verified: if the build succeeds, the machine has exactly what the flake says.
machine0 treats NixOS as a first-class image family. The images are built with Nix flakes that are open source in the machine0-nixos repository, so you can read exactly what is on the machine and extend it.
## The NixOS images
| Image | What it includes |
|---|---|
nixos-25-11-loaded | NixOS 25.11 plus a modern shell and dev tools |
nixos-25-11 | NixOS 25.11, minimal |
nixos-25-11-openclaw | NixOS 25.11 plus OpenClaw |
nixos-25-11-hermes | NixOS 25.11 plus Hermes |
nixos-25-11-nvidia | NixOS 25.11 plus NVIDIA drivers, CUDA and GPU containers, for NVIDIA GPU sizes |
The SSH user on a provisioned NixOS VM is nix, root login is disabled, and the user has full sudo. Create one with:
machine0 new devbox --image nixos-25-11-loaded --size large
machine0 ssh devbox## Three ways to build a machine from a flake
**Provision a running VM**
machine0 provision applies a flake to an existing VM, the way nixos-rebuild switch --flake would on the machine itself. Clone the machine0-nixos repository, change the configuration, and apply it:
git clone https://github.com/fdmtl/machine0-nixos.git ./
claude -p "Add postgres to the loaded profile"
machine0 provision devbox ./flake.nix#loadedThis is the fastest loop while you are iterating on a configuration, because the VM is already up and each apply only builds what changed.
**Build an image server-side**
machine0 images new --flake builds the flake into an image without touching any VM you own. machine0 starts a temporary builder VM, applies the flake, snapshots the result into an image and destroys the builder. The builder bills like a normal machine for the minutes it runs, defaults to the large size, and its disk sets the minimum size for VMs created from the image.
machine0 images new web --flake 'github:acme/infra#web01'
machine0 new web-1 --image web --size xlThe flake reference accepts ?ref= for a branch, ?rev= for a 40-character commit pin and ?dir= for a subdirectory, and the #attr names the nixosConfigurations attribute. A ?rev= pin must name its branch alongside it. Private repositories work when GitHub is connected to your account and the installation includes the repo. Local folder flakes work from the CLI with --flake ./dir#attr, which uploads the folder.
Images built from a GitHub flake track their branch. With the machine0 GitHub App installed on the repository, every push to the tracked branch builds a new version on top of the image's current version, boot-tests it and promotes it once that passes, and each version records the exact commit it came from. Promotion never downgrades: if you promote a newer version yourself while an automatic build is running, the automatic one finishes as a draft. The image keeps the version each promotion replaces, so machine0 images versions restore <image> goes one step back. Once an image follows a flake, the flake can't be changed or turned off, and a VM snapshot or a local-folder build onto it is refused, so content that did not come from the repo can never replace it. To make an image you already have follow a flake, run machine0 images update <image> --flake 'github:owner/repo#attr'.
**Let the skill write the flake**
If you would rather describe the machine than write Nix, install the machine0 skills into your local coding agent and ask for one:
machine0 skills install
claude -p "/create-machine a server that auto-starts claude code in tmux on boot"
ls -l claude-in-tmux/
machine0 ssh claude-in-tmux
tmux attachThe /create-machine skill turns the description into a git-versioned NixOS project, builds a VM from it and leaves you with the code to extend.
## Snapshot and clone
Once a VM is the way you want it, make it a golden image. Snapshots are regular versioned images, so you can promote, roll back and remove versions.
machine0 stop devbox
machine0 images new devbox devbox-gm
machine0 rm devbox
machine0 new devbox --image devbox-gm --size xxlClones can use any size with enough disk, which is how you move a configured machine from a large to a 6xl for a heavy job and back. Snapshots of a GPU VM keep the drivers baked in and stay GPU-compatible, so parking GPU work on a cheap size and resuming on a GPU size later is a normal workflow.
## NixOS on GPUs
The nixos-25-11-nvidia image ships the NVIDIA driver stack, CUDA and the container toolkit, so there is no driver setup and docker --gpus all works at first boot. It runs on gpu-4000ada-1, gpu-6000ada-1 and gpu-h100-1. GPU sizes select an Ubuntu-based GPU image by default, so pass the image explicitly, and list it with --all since GPU-only system images are hidden by default:
machine0 images ls --all
machine0 new ml --image nixos-25-11-nvidia --size gpu-h100-1
machine0 ssh ml
docker run --rm --gpus all nvidia/cuda:12.4.0-base-ubuntu22.04 nvidia-smiAMD MI300X sizes are not supported by that image.
## Cost and leaving
A NixOS VM costs the same as any VM of its size: small at $0.013 per hour, large at $0.052, xxl at $0.208, billed by the minute with no commitment. Suspending a VM stops compute billing and keeps the disk as a snapshot at about $0.078 per GB per month. Server-side image builds bill the builder VM for the minutes it runs.
Because the operating system is a flake, there is nothing holding you to machine0. The same flake builds on any NixOS host, and machine0 sync pull copies your data down before you destroy a machine.
## FAQ
Which NixOS image should I start from?
nixos-25-11-loaded for development, since it includes a modern shell and dev tools. nixos-25-11 is minimal. nixos-25-11-openclaw and nixos-25-11-hermes come with those agents installed, and nixos-25-11-nvidia is for NVIDIA GPU sizes.
What is the SSH user on a NixOS VM?
nix. Root login is disabled and the user has full sudo. Ubuntu images use ubuntu instead.
What is the difference between provision and images new --flake?
provision applies a flake to an existing VM, like nixos-rebuild switch. images new --flake builds the flake on a temporary builder VM, snapshots it into an image, and destroys the builder, so you get a reusable image rather than one configured machine.
Do I need to rebuild images by hand when the flake changes?
Not for GitHub flakes. With the machine0 GitHub App installed on the repo, each push to the tracked branch builds a new version on top of the current one, boot-tests it and promotes it on success. If a version turns out bad, machine0 images versions restore goes back to the previous one.
Can I run NixOS on a GPU?
Yes, with the nixos-25-11-nvidia image on the gpu-4000ada-1, gpu-6000ada-1 and gpu-h100-1 sizes. It ships the NVIDIA driver stack, CUDA and the container toolkit, so docker --gpus all works at boot. AMD MI300X sizes are not supported by that image.
What does a NixOS VM cost?
The same as any VM of that size. A large VM is $0.052 per hour, billed by the minute, and a suspended VM pays only image storage at about $0.078 per GB per month. A server-side image build bills its builder VM for the minutes it runs.