Install OpenClaw on NixOS with lazydocker

OpenClaw is easiest to operate when the host is boring, repeatable, and quick to debug. That makes NixOS a good fit for self-hosted AI agents. You can define Docker, Node.js, and support tools declaratively, then use lazydocker when you need to inspect containers without typing a long chain of Docker commands.
This guide shows a practical NixOS setup for running OpenClaw on a small VM, home server, or internal automation box.
Why NixOS for OpenClaw
OpenClaw runs long-lived gateway processes, message connectors, cron jobs, and local tools. On a normal Linux host, that can slowly turn into a hand-maintained machine with unclear package state.
NixOS helps by keeping the host definition in code:
- Docker is enabled from the same config that installs the CLI tools.
- Node.js is pinned through Nix packages instead of whatever the host happened to have.
- Rollbacks are built into the OS generation model.
- The server can be rebuilt from Git if the VM is lost.
For SRE teams, the benefit is simple: your AI automation host becomes another reviewed infrastructure artifact.
What lazydocker Adds
The lazydocker README describes it as a simple terminal UI for Docker and Docker Compose, written in Go with the gocui library. In practice, it is useful because it gives operators one fast screen for common container work:
- Inspect running containers, images, volumes, and Compose services.
- Tail logs without remembering container names.
- Restart or stop services during local troubleshooting.
- Check resource usage while an agent workflow is running.
- Clean up unused Docker objects after experiments.
For an OpenClaw host, lazydocker is not required. It is a convenience layer. When a connector fails, an image pull gets stuck, or a local service consumes too much memory, it shortens the path from alert to evidence.
NixOS Host Configuration
Start by enabling Docker and installing the tools you need on the host. Add something like this to your NixOS configuration:
{ pkgs, ... }:
{
virtualisation.docker.enable = true;
environment.systemPackages = with pkgs; [
docker-compose
git
lazydocker
nodejs_22
];
users.users.openclaw = {
isNormalUser = true;
extraGroups = [ "docker" ];
};
}
Apply it:
sudo nixos-rebuild switch
Then log out and back in so the docker group membership is active.
Install OpenClaw
OpenClaw is distributed through npm, so use the Node.js runtime from Nix and keep global npm packages in the user home directory:
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
export PATH="$HOME/.npm-global/bin:$PATH"
npm install -g openclaw@latest
openclaw --help
Persist the path in your shell profile:
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.profile
Now initialize OpenClaw and start the gateway:
openclaw setup
openclaw gateway start
openclaw gateway status
Use openclaw doctor after setup to catch missing configuration, connector problems, or runtime issues before you depend on the host for real automation.
Watch the Stack with lazydocker
Once Docker workloads are running, launch:
lazydocker
Use it during setup to confirm that supporting services are healthy. It is especially helpful when you run databases, browser automation helpers, observability collectors, or local model infrastructure next to OpenClaw.
A useful first-pass workflow:
- Start OpenClaw and any Docker-backed dependencies.
- Open
lazydocker. - Check container status and recent logs.
- Restart only the failing service if configuration changes.
- Run
openclaw gateway statusandopenclaw logs --followfor application-level confirmation.
That split works well: lazydocker shows the container layer, OpenClaw CLI shows the agent layer.
Operational Tips
Keep the NixOS config in Git. The OpenClaw host should be easy to recreate, not a special snowflake.
Pin important runtime choices. If your workflows depend on a specific Node.js major version, declare it in NixOS and review upgrades like any other platform change.
Avoid running everything as root. A dedicated openclaw user with Docker access is usually enough for a small self-hosted setup. For stricter environments, isolate services further and avoid mounting sensitive host paths into containers.
Back up ~/.openclaw. That directory contains configuration, skills, state, and memory files. NixOS can rebuild the system, but it will not recreate your operational history unless you back it up.
Quick Reference
# Rebuild host config
sudo nixos-rebuild switch
# Install OpenClaw with Node.js supplied by Nix
npm install -g openclaw@latest
# Start and inspect OpenClaw
openclaw setup
openclaw gateway start
openclaw gateway status
openclaw logs --follow
# Inspect Docker services
lazydocker
Conclusion
NixOS gives OpenClaw a reproducible base. lazydocker gives operators a fast way to inspect the Docker layer when something needs attention. Together, they make a small self-hosted AI automation server easier to rebuild, debug, and trust.
If you are building AI-native operations workflows, Akmatori helps teams automate incident response and reduce alert fatigue. To run the services behind those workflows with low latency worldwide, check out Gcore.
