agent-sandbox provides a Nix package for running agents in an opinionated Bubblewrap sandbox.
Note
Currently, only Pi and Claude Code are wired up. Contributions to include more agents are welcome!
You can run it directly with the default configuration to use the current directory as the working directory.1
nix run github:interrato/agent-sandboxAlternatively, you can add it to your NixOS configuration.
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
agent-sandbox = {
url = "github:interrato/agent-sandbox";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, agent-sandbox, ... }: {
nixosConfigurations.yourhost = nixpkgs.lib.nixosSystem {
modules = [
{
environment.systemPackages = [
agent-sandbox.packages.x86_64-linux.default
];
}
];
};
};
}You can use override to customize the agent package. The following options are currently available.
The name of the agent that will run.
The Nix package that contains the agent program binary. The default value automatically selects one from Nixpkgs.
The path to the agent program binary. The default value automatically selects a valid path, ignoring agentPackage.
Environment variables to set for the sandboxed environment.
Important
The API key variables for the most common providers pass through from the host by default and cannot be overridden.
Extra packages to include in the sandboxed environment.
The name of the terminfo entry used to determine the capabilities of the terminal.
A path containing the selected terminfo entry.
Here is an example for Ghostty.
agent-sandbox.packages.x86_64-linux.default.override {
packages = [ pkgs.ghostty.terminfo ];
TERM = "xterm-ghostty";
TERMINFO = "${pkgs.ghostty.terminfo}/share/terminfo";
}Whether to enable network sharing and include networking tools.
Whether to include tools for content downloading, web scraping, and browser testing.
Whether to include tools for reading, editing, and creating PDFs.
Whether to include tools for manipulating various document formats, such as spreadsheets, presentations, and word processing documents.
Whether to include tools for performing cryptographic operations.
Whether to include proof assistants and formal verification tools.
Whether to include Node.js.
Whether to include a Python environment with some packages, depending on the options above.
Footnotes
-
Some directories, such as
$HOME, are considered too sensitive, andagentwill refuse to run. ↩
