A full VM environment that is safe and can recursively run itself, great for agents to work on self-improving their environment.
Status: Prototyping
Most exploring concepts around ideas here: shazow/shazow.net#87
- Agentspace is a nix flake that has two library outputs with high-level consumer APIs:
lib.mkSandboxproduces a sandbox VM configuration with the help ofmicrovm.nix, check sandbox-qemu.nix for all the options.lib.mkLaunchtakes the sandbox output and wires it up into an executable script that runs the VM withvirtie.
- Virtie handles running a bunch if processes and wiring them up together, including:
virtiofsdfor volume mounts,qemufor the VM, notification hooks, socket sharing, memory ballooning, and other things.
Virtie is rapidly evolving, but the agentspace consumer interface should remain fairly stable.
There's a couple of examples:
- Minimal example used for testing: ./examples/agent/
- Start here: Practical example used day to day: github:shazow/nixfiles?dir=vms/agentspace -- remove anything you don't need!
But to recap, here's a flake you can make to give it a try:
{
inputs = {
agentspace.url = "github:shazow/agentspace";
};
outputs =
{
agentspace,
...
}:
let
sandbox = agentspace.lib.mkSandbox {
# Where should the VM images and filesystem overlays live? Defaults to $PWD if empty, but that's messy
persistence.baseDir = "/home/shazow/vms/agentspace";
ssh.authorizedKeys = [
# Put your SSH public keys in here, one string per list item
#"ssh-ed25519 AAAAC3N..."
];
# VM settings
#machine.vcpu = 8; # Default: Use all available cores (recommended unless you want a slow VM)
machine.memory = 8 * 1024;
# Additional mounts and port forwards can be configured directly:
#shares = [];
#volumes = [];
#forwardPorts = [];
# NixOS modules
#extraModules = [];
# home-manager modules for the primary user:
#homeModules = [];
# Optional host-side processes managed with the VM.
#run = [
# {
# vars.SocketDir = "/tmp/agentspace-sockets";
# exec = [ "xdg-dbus-proxy" "{{.Env.DBUS_SESSION_BUS_ADDRESS}}" "{{.SocketDir}}/dbus-notifications.sock" "--filter" ];
# }
#];
};
in
{
nixosConfigurations.agentspace = sandbox;
apps."x86_64-linux" = {
default = {
type = "app";
program = agentspace.lib.mkLaunch sandbox;
};
};
};
}MIT