Install on NixOS
Run HolaClaw Server on NixOS with the flake's module, on the host, in a NixOS container, or in a microVM, and declare its config in Nix.
- Server
- Installation
- NixOS
- Nix
The HolaClaw Server flake exports a NixOS module, a package, an overlay and the container images. The module installs the same hardened systemd units as the other Linux installs. It works on Linux only.
| Output | What it is |
|---|---|
nixosModules.default |
the NixOS module, services.holaclaw |
packages.<system>.holaclaw |
the binary |
overlays.default |
adds holaclaw to pkgs |
packages.<system>.container, packages.<system>.container-slim |
the container images, with and without the browser |
Step 1: Enable the module
Add the flake to your inputs, and holaclaw.nixosModules.default to your system's modules:
# flake.nix
inputs.holaclaw.url = "github:ikitana/holaclaw";# configuration.nix
services.holaclaw = {
enable = true;
# `holaclaw init` sets `server.secrets_dir` to the `secrets` directory
# inside the config directory. This option must match it.
secretsDir = "/etc/holaclaw/secrets";
browser.enable = true; # optional: runs the browser sidecar with Chromium and Xvfb
};Switch to the new configuration. The service fails until a config exists; the next step creates it.
Step 2: Initialise
Run init with your provider, adding --config /etc/holaclaw, then restart the service. For OpenRouter, which asks for the API key:
sudo -u holaclaw holaclaw init --config /etc/holaclaw --provider openrouter --token-file /etc/holaclaw/token
sudo systemctl restart holaclawThe other providers are in Providers and models.
Step 3: Chat
sudo -u holaclaw holaclaw --config /etc/holaclaw chatThe unit sets HOLACLAW_CONFIG, but your shell does not. Pass --config /etc/holaclaw, or set HOLACLAW_CONFIG=/etc/holaclaw, whenever you run a command as the holaclaw user.
With a ChatGPT subscription, sign in first with login codex. Continue with Your first chat.
Declare the config in Nix
You can declare config.toml, channels.toml and the agents in Nix instead of writing them with init. If config.toml already exists, init only creates the database and the owner.
environment.etc = let
file = source: {
inherit source;
# With a mode, NixOS copies the file instead of linking it to the store.
mode = "0440";
user = "holaclaw";
group = "holaclaw";
};
in {
"holaclaw/config.toml" = file ./config.toml;
"holaclaw/channels.toml" = file ./channels.toml;
# Declare agents file by file, so that agents/ stays a directory.
"holaclaw/agents/main/agent.toml" = file ./agents/main/agent.toml;
"holaclaw/agents/main/prompt.md" = file ./agents/main/prompt.md;
};
# NixOS creates the parent directories of these files as root, mode 0700. The
# daemon cannot read them, so give them to holaclaw.
systemd.tmpfiles.settings.holaclaw-agents = {
"/etc/holaclaw/agents".d = { user = "holaclaw"; group = "holaclaw"; mode = "0700"; };
"/etc/holaclaw/agents/main".d = { user = "holaclaw"; group = "holaclaw"; mode = "0700"; };
};Set
server.secrets_dirin yourconfig.tomlto the module'ssecretsDir.initwrites it for you, but a declaredconfig.tomlhas to say it itself. Without it, HolaClaw Server looks for/etc/holaclaw-secrets, which the module does not create, andholaclaw auth setfails with "permission denied":toml[server] secrets_dir = "/etc/holaclaw/secrets"Set
modeon every file. Without it, the file is a symlink with mode0777.holaclaw checkdoes not follow symlinks, so it reportsSEC005(world-writable).These files are read-only, and every switch rewrites them. Edit them in Nix, not on the machine.
The rest of the config directory keeps its state: the data directory, the secrets and the owner's token.
What goes in each file is in Configuration overview.
Run it isolated
On NixOS, the exec tool runs commands from /run/current-system/sw/bin, so it can run every program installed on the machine. If the machine does anything besides HolaClaw Server, run it in a NixOS container or a VM, and install there only the programs you want exec to use. Every option below uses the same module.
NixOS container
The container runs under systemd-nspawn and shares the host's kernel.
containers.holaclaw = {
autoStart = true;
# Maps container users to unprivileged host users. Without it, root in the
# container is root on the host.
privateUsers = "pick";
config = {
imports = [ holaclaw.nixosModules.default ];
services.holaclaw = {
enable = true;
secretsDir = "/etc/holaclaw/secrets";
};
environment.systemPackages = [ ]; # the programs exec can run
system.stateVersion = "26.05";
};
};nixos-container run holaclaw -- runuser -u holaclaw -- holaclaw init --config /etc/holaclaw --provider openrouter --token-file /etc/holaclaw/token
nixos-container run holaclaw -- systemctl restart holaclaw
nixos-container run holaclaw -- runuser -u holaclaw -- env HOLACLAW_CONFIG=/etc/holaclaw holaclaw statusTo run holaclaw from the host, install a wrapper that runs the CLI inside the container as the holaclaw user. nixos-container run passes the terminal through, so chat and the other full-screen commands work too:
environment.systemPackages = [
(pkgs.writeShellApplication {
name = "holaclaw";
text = ''
if [ "$(id -u)" -ne 0 ]; then
exec /run/wrappers/bin/sudo "$0" "$@"
fi
exec nixos-container run holaclaw -- \
runuser -u holaclaw -- env HOLACLAW_CONFIG=/etc/holaclaw holaclaw "$@"
'';
})
];- The container uses the host's network, so it reaches an Ollama on the host at
localhost:11434. If a host name resolves on the host but not in the container (a tailnet name, for example), put the IP address inbase_url. - The container keeps its files in
/var/lib/nixos-containers/holaclaw. privateUsersrequires/nix/storeon a filesystem that supports idmapped mounts: ext4, btrfs, xfs, or ZFS 2.2 and later. On other filesystems the container does not start.
MicroVM
microvm.nix runs HolaClaw Server in a VM with its own kernel. This is the strongest isolation, and the one to use with the browser: an attacker who escapes Chromium ends up in the VM, not on the host. Set up host networking for the tap interface as microvm.nix's documentation describes.
# flake inputs: microvm.url = "github:microvm-nix/microvm.nix";
imports = [ microvm.nixosModules.host ];
microvm.vms.holaclaw.config = {
imports = [ microvm.nixosModules.microvm holaclaw.nixosModules.default ];
microvm = {
vcpu = 2;
mem = 4096;
interfaces = [{ type = "tap"; id = "vm-holaclaw"; mac = "02:00:00:00:00:01"; }];
shares = [{ proto = "virtiofs"; tag = "ro-store"; source = "/nix/store"; mountPoint = "/nix/.ro-store"; }];
# The VM loses its root filesystem on reboot. Keep config, secrets and
# state on volumes. The secrets are in /etc/holaclaw/secrets.
volumes = [
{ image = "config.img"; mountPoint = "/etc/holaclaw"; size = 64; }
{ image = "state.img"; mountPoint = "/var/lib"; size = 4096; }
];
};
services.holaclaw = {
enable = true;
secretsDir = "/etc/holaclaw/secrets";
browser.enable = true;
};
system.stateVersion = "26.05";
};This setup is not tested in CI.
Dedicated VM or server
Install NixOS on it and enable the module as in step 1.
Upgrade and remove
- Upgrade: update the flake input and switch, then run
holaclaw config migrate. - Remove: set
enable = falseand switch. The config directory and the state stay on disk.
Related
Was this page helpful?
