April 22, 2026
How to Install OpenClaw with Nix: A Clean, Upgradable Setup Guide
Learn how to install OpenClaw using the Nix package manager for a reproducible, clean, and easily upgradable environment. This guide covers configuration paths, best practices for Nix users, and how to keep your OpenClaw stack tidy and up-to-date.
Introduction
OpenClaw has quickly become a go-to orchestration platform for modern, scalable infrastructure. If you're a developer or operator who values reproducibility and clean environments, installing OpenClaw with Nix is an excellent choice. This guide walks you through a practical, zero-fluff setup using nix-openclaw, with tips on configuration paths, upgrades, and keeping your system tidy.
Whether you're experimenting locally, deploying to production, or integrating with platforms like Clawbase, leveraging Nix means you get predictable builds and easy rollbacks. Let's get started.
Why Install OpenClaw with Nix?
Nix is a powerful package manager that guarantees reproducible builds and isolated environments. Using Nix to install OpenClaw offers several advantages:
- Clean State: No more polluting
/usr/localor system Python installs. - Declarative Configs: Your OpenClaw environment is defined in code, making upgrades and rollbacks trivial.
- Easy Upgrades: Update OpenClaw and its dependencies with a single command.
- Multiple Versions: Run different OpenClaw versions side by side for testing or migration.
For teams using Clawbase or managing multiple clusters, these benefits translate into faster onboarding and fewer headaches.
Prerequisites
Before you begin, ensure you have:
- A working Nix installation (NixOS, macOS, or Linux)
- Basic familiarity with the command line
- Optional: direnv for automatic environment activation
Note: If you're new to Nix, the Nix Pills are a great resource for learning the basics.
Installing OpenClaw with Nix
The OpenClaw team maintains nix-openclaw, a set of Nix expressions for installing and managing OpenClaw. There are two main ways to use it:
- Imperative install (quick, one-off)
- Declarative install (recommended for clean, upgradable setups)
Let's walk through both approaches.
1. Imperative Install (Quick Start)
If you want to try OpenClaw immediately, you can use nix-shell or nix run for an ephemeral environment:
nix run github:openclaw/nix-openclaw
This downloads and runs the latest OpenClaw CLI in a sandboxed environment. Nothing is installed globally, and your base system remains untouched.
- Pros: Fast, zero setup, no config files needed
- Cons: Not persistent, not ideal for upgrades or production
2. Declarative Install (Recommended)
For a robust, upgradable workflow, define OpenClaw in your flake.nix or shell.nix.
Ready for your own?
🦞 Hire an AI employee that works 24/7
Plans from less than $1/day. Dedicated cloud host, top models, and messaging on Telegram, Slack, or Discord. No API keys to manage.
See plans · Cancel anytime
Using Flakes (Modern Nix)
If your project uses Nix flakes, add nix-openclaw as an input:
{
description = "OpenClaw dev environment";
inputs.openclaw.url = "github:openclaw/nix-openclaw";
outputs = { self, nixpkgs, openclaw }: {
devShells.default = nixpkgs.lib.mkShell {
buildInputs = [ openclaw.packages.x86_64-linux.openclaw ];
};
};
}
Now, enter the environment:
nix develop
This gives you the openclaw CLI, isolated from your system packages.
Using shell.nix (Classic Nix)
If you're not using flakes, create a shell.nix:
let
openclaw = import (fetchTarball "https://github.com/openclaw/nix-openclaw/archive/main.tar.gz");
in
{
buildInputs = [ openclaw.openclaw ];
}
Then run:
nix-shell
This approach is compatible with most Nix workflows and CI systems.
Managing Configuration Paths and State
One of the best practices for Nix users is to keep configuration and state outside the ephemeral build environment. This ensures upgrades and rollbacks don't affect your data.
Where OpenClaw Stores Data
By default, OpenClaw will look for its configuration and state in your home directory, typically under ~/.openclaw/. You can override this by setting the OPENCLAW_HOME environment variable:
export OPENCLAW_HOME="$HOME/.config/openclaw"
Consider versioning your config files (e.g., with Git) for easy rollbacks and team collaboration.
Tips for Clean State
- Avoid writing state inside
/nix/store: It's immutable and will break upgrades. - Use
$XDG_CONFIG_HOME: For portable configs, setOPENCLAW_HOMEto$XDG_CONFIG_HOME/openclaw. - Back up your config/state: Especially before major upgrades.
Upgrading OpenClaw with Nix
One of the biggest advantages of Nix is painless upgrades. Here’s how to keep OpenClaw up-to-date:
- With Flakes:
- Update your flake inputs:
nix flake update - Re-enter your shell:
nix develop
- Update your flake inputs:
- With
shell.nix:- Update the
fetchTarballURL if needed - Run
nix-shellagain
- Update the
Nix will build the new version in isolation, so you can always roll back if something breaks.
Rolling Back
If an upgrade causes issues, simply revert your flake.lock or shell.nix to the previous commit. Nix ensures the previous environment is reproducible.
Using OpenClaw with Clawbase
Clawbase is a popular managed service for OpenClaw users. If you're integrating with Clawbase, the Nix approach makes it easy to:
- Keep local and production versions in sync
- Share reproducible dev shells across your team
- Test new OpenClaw releases safely before deploying to Clawbase
Just point your OpenClaw config to the Clawbase endpoint as per their documentation. Nix ensures your CLI environment matches your target stack.
Troubleshooting Common Issues
Even with Nix, you may run into some common issues. Here’s how to resolve them:
Problem: "Command not found" after entering shell
- Solution: Ensure
openclawis inbuildInputsand your shell is reloaded. Trywhich openclawto confirm.
Problem: Permissions or immutable store errors
- Solution: Never write state to
/nix/store. Always setOPENCLAW_HOMEto a writable location.
Problem: Dependency conflicts or broken builds
- Solution: Pin your Nixpkgs and
nix-openclawversions. Use flakes for easier version management.
Best Practices for Nix-OpenClaw Users
- Keep configs out of the store: Always use user-writable paths for state.
- Use declarative configs: Prefer
flake.nixorshell.nixfor reproducibility. - Leverage direnv: Automate environment activation with direnv and a
.envrcfile:
use nix
- Version your configs: Use Git to track changes to OpenClaw and Nix files.
- Test upgrades locally: Try new OpenClaw versions in a separate shell before rolling out.
Conclusion
Installing OpenClaw with Nix gives you a clean, reproducible, and easily upgradable environment—ideal for both individual developers and teams. By following the declarative approach and keeping your configuration paths tidy, you can avoid the usual pitfalls of system package management.
Whether you're running OpenClaw locally, integrating with Clawbase, or managing large clusters, Nix ensures your setup is always predictable and easy to maintain. For more details and advanced usage, check out the official documentation and nix-openclaw GitHub repo.
Happy hacking!