Nix 安装
使用 Nix 运行 Moltbot 的推荐方式是通过 nix-moltbot —— 开箱即用的 Home Manager 模块。
快速开始
将以下内容粘贴给你的 AI 助手(Claude、Cursor 等):
I want to set up nix-moltbot on my Mac.
Repository: github:moltbot/nix-moltbot
What I need you to do:
1. Check if DeStop Nix is installed (if not, install it)
2. Create a local flake at ~/code/moltbot-local using templates/agent-first/flake.nix
3. Help me create a Telegram bot (@BotFather) and get my chat ID (@userinfobot)
4. Set up secrets (bot token, Anthropic key) - plain files at ~/.secrets/ is fine
5. Fill in the template placeholders and run home-manager switch
6. Verify: launchd running, bot responds to messages
Reference the nix-moltbot README for module options.📦 完整指南:github.com/moltbot/nix-moltbot
nix-moltbot 仓库是 Nix 安装的权威来源,本页仅为简要概览。
你将获得
- Gateway + macOS 应用 + 工具(whisper、spotify、cameras)—— 版本均固定
- 重启后仍存在的 Launchd 服务
- 声明式配置的插件系统
- 一键回滚:
home-manager switch --rollback
Nix 模式运行时行为
当设置 CLAWDBOT_NIX_MODE=1 时(使用 nix-moltbot 时会自动设置):
Moltbot 支持 Nix 模式,使配置可复现并关闭自动安装流程。
通过以下方式启用:
CLAWDBOT_NIX_MODE=1在 macOS 上,图形应用不会自动继承 shell 环境变量。也可通过 defaults 启用 Nix 模式:
defaults write bot.molt.mac moltbot.nixMode -bool true配置与状态路径
Moltbot 从 CLAWDBOT_CONFIG_PATH 读取 JSON5 配置,在 CLAWDBOT_STATE_DIR 存放可变数据。
CLAWDBOT_STATE_DIR(默认:~/.clawdbot)CLAWDBOT_CONFIG_PATH(默认:$CLAWDBOT_STATE_DIR/moltbot.json)
在 Nix 下运行时,建议显式设为 Nix 管理的位置,使运行时状态与配置不进入不可变 store。
Nix 模式下的运行时行为
- 自动安装与自修改流程被关闭
- 缺少依赖时会给出 Nix 专用的修复说明
- UI 在启用时显示只读的 Nix 模式横幅
打包说明(macOS)
macOS 打包流程期望在以下路径有稳定的 Info.plist 模板:
apps/macos/Sources/Moltbot/Resources/Info.plistscripts/package-mac-app.sh 会将该模板复制到 app bundle 并修补动态字段(bundle ID、版本/构建号、Git SHA、Sparkle 密钥),使 plist 对 SwiftPM 打包和 Nix 构建保持确定(Nix 构建不依赖完整 Xcode 工具链)。
相关
- nix-moltbot — 完整配置指南
- 向导 — 非 Nix CLI 配置(若存在)
- Docker — 容器化部署(若存在)
最后更新于: