Setting up ephemeral virtual machines on NixOS using microvm.nix provides a safe sandbox for running AI coding agents without exposing personal files. The approach uses declarative configuration to create disposable VMs with shared workspaces, network isolation via bridge networking and NAT, and integration with tools like Claude Code. The setup includes network configuration with systemd-networkd, shared directories for workspaces and Nix store, and project-specific package environments. Claude Skills can automate the creation of new MicroVMs by analyzing existing configurations and generating similar structures. This method enables running untrusted code safely while maintaining minimal maintenance overhead through NixOS's declarative model.

12m read timeFrom michael.stapelberg.ch
Post cover image
Table of contents
See alsoSetting up microvm.nixCreating VMs with ClaudeReplicating this setup with Claude CodeConclusion

Sort: