Files
zeekayandHanzo Dev 84e4069c2c docs name the state dir and config file the bot reads: ~/.bot/bot.json
The docs said ~/.hanzo-bot/hanzo-bot.json (and ~/.hanzo-bot-<profile>, hanzo-bot.plugin.json), which nothing reads: src/config/paths.ts resolves ~/.bot, bot.json and ~/.bot-<profile>, and plugins ship bot.plugin.json. Every such path in docs/ now names what the code opens.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-24 21:12:09 -07:00

3.4 KiB
Raw Permalink Blame History

read_when, summary, title, x-i18n
read_when summary title x-i18n
你想要可复现、可回滚的安装
你已经在使用 Nix/NixOS/Home Manager
你想要所有内容都固定并以声明式管理
使用 Nix 声明式安装 HanzoBot Nix
generated_at model provider source_hash source_path workflow
2026-02-03T07:49:51Z claude-opus-4-5 pi f1452194cfdd74613b5b3ab90b0d506eaea2d16b147497987710d6ad658312ba install/nix.md 15

Nix 安装

使用 Nix 运行 HanzoBot 的推荐方式是通过 nix-hanzo-bot — 一个开箱即用的 Home Manager 模块。

快速开始

将此粘贴给你的 AI 智能体(Claude、Cursor 等):

I want to set up nix-hanzo-bot on my Mac.
Repository: github:hanzo-bot/nix-hanzo-bot

What I need you to do:
1. Check if Determinate Nix is installed (if not, install it)
2. Create a local flake at ~/code/hanzo-bot-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-hanzo-bot README for module options.

📦 完整指南:github.com/hanzo-bot/nix-hanzo-bot

nix-hanzo-bot 仓库是 Nix 安装的权威来源。本页只是一个快速概述。

你将获得

  • Gateway 网关 + macOS 应用 + 工具(whisper、spotify、cameras)— 全部固定版本
  • 重启后仍能运行的 Launchd 服务
  • 带有声明式配置的插件系统
  • 即时回滚:home-manager switch --rollback

Nix 模式运行时行为

当设置 BOT_NIX_MODE=1 时(nix-hanzo-bot 会自动设置):

HanzoBot 支持 Nix 模式,使配置确定性并禁用自动安装流程。 通过导出以下环境变量启用:

BOT_NIX_MODE=1

在 macOS 上,GUI 应用不会自动继承 shell 环境变量。你也可以通过 defaults 启用 Nix 模式:

defaults write bot.molt.mac hanzo-bot.nixMode -bool true

配置 + 状态路径

HanzoBot 从 BOT_CONFIG_PATH 读取 JSON5 配置,并将可变数据存储在 BOT_STATE_DIR 中。

  • BOT_STATE_DIR(默认:~/.bot)
  • BOT_CONFIG_PATH(默认:$BOT_STATE_DIR/bot.json)

在 Nix 下运行时,将这些显式设置为 Nix 管理的位置,以便运行时状态和配置不会进入不可变存储。

Nix 模式下的运行时行为

  • 自动安装和自我修改流程被禁用
  • 缺失的依赖会显示 Nix 特定的修复消息
  • 存在时 UI 会显示只读 Nix 模式横幅

打包注意事项(macOS)

macOS 打包流程期望在以下位置有一个稳定的 Info.plist 模板:

apps/macos/Sources/HanzoBot/Resources/Info.plist

scripts/package-mac-app.sh 将此模板复制到应用包中并修补动态字段(bundle ID、版本/构建号、Git SHA、Sparkle 密钥)。这使 plist 对于 SwiftPM 打包和 Nix 构建保持确定性(它们不依赖完整的 Xcode 工具链)。

相关内容