refactor: thread agent packages via option, drop overlay and forge-tools shim

This commit is contained in:
müde 2026-07-13 21:43:26 +02:00
commit 281667d5a8
13 changed files with 139 additions and 168 deletions

View file

@ -195,7 +195,7 @@ in
SHELL = "${pkgs.bashInteractive}/bin/bash";
HOME = homeDir;
HIVE_STATIC_DIR = "${config.hyperhive.frontend.mergedDist}";
HIVE_ASSETS_DIR = "${pkgs.hyperhive-assets}/share/hyperhive";
HIVE_ASSETS_DIR = "${config.hyperhive.packages.assets}/share/hyperhive";
# Unix-socket path for the harness web UI. All agents always bind
# here; there is no TCP fallback. Path matches
# `hive_c0re::agent_sockets::socket_path_for(name)` so lifecycle
@ -226,7 +226,7 @@ in
HIVE_EXTRA_WEB_PROXIES = builtins.toJSON config.hyperhive.extraWebProxies;
};
serviceConfig = {
ExecStart = "${pkgs.hive-agent}/bin/${binary}";
ExecStart = "${config.hyperhive.packages.hive-agent}/bin/${binary}";
# Pin the journal identity to the binary name (otherwise systemd
# derives SyslogIdentifier from the ExecStart basename).
SyslogIdentifier = binary;

View file

@ -265,7 +265,7 @@ in
# `hivectl choom`) so no launch wrapper is needed.
environment.etc."claude-code/managed-settings.json".source =
let
baseSettings = "${pkgs.hyperhive-assets}/share/hyperhive/prompts/claude-settings.json";
baseSettings = "${config.hyperhive.packages.assets}/share/hyperhive/prompts/claude-settings.json";
# Merge base env (always) with OTEL env (when enabled). jq is always
# run — `baseClaudeEnv` contains per-agent values (e.g.
# CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX) that can't live in the

View file

@ -31,6 +31,7 @@
./matrix.nix
./mcp.nix
./network.nix
./packages.nix
./user.nix
./weston-vnc.nix
];
@ -153,22 +154,24 @@
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [ "claude-code" ];
# Core tooling every agent gets. Per-bin split packages (see
# nix/packages/default.nix) rather than the full `pkgs.hyperhive`
# bundle — that bundle also carries `hivectl` (a host-admin CLI
# that dials the *host* admin socket — useless and unreachable
# from inside a container — wrapped with `wireguard-tools` for
# `hivectl wg`). The daemon/harness/MCP bins the harness execs
# (hive-agent{,-mcp}, hive-bash-daemon, hive-matrix-daemon,
# hive-bash-mcp, hive-matrix-mcp) are wired via their own
# ExecStart/command lines in the sibling modules with the matching
# `pkgs.hive-*` package — they don't need to be on PATH too. Only
# these two are actually looked up on PATH by claude/shell code
# inside the container: `hive-agent-wake` (external wake CLI,
# docs/turn-loop/mcp.md) and `hive-metric` (agent-emitted custom
# metrics CLI, docs/observability.md).
environment.systemPackages = with pkgs; [
hive-agent-wake
hive-metric
# nix/packages/default.nix + ./packages.nix) rather than the full
# `hyperhive` bundle — that bundle also carries `hivectl` (a
# host-admin CLI that dials the *host* admin socket — useless and
# unreachable from inside a container — wrapped with
# `wireguard-tools` for `hivectl wg`). The daemon/harness/MCP bins
# the harness execs (hive-agent{,-mcp}, hive-bash-daemon,
# hive-matrix-daemon, hive-bash-mcp, hive-matrix-mcp) are wired via
# their own ExecStart/command lines in the sibling modules — they
# don't need to be on PATH too. Only these two are actually looked
# up on PATH by claude/shell code inside the container:
# `hive-agent-wake` (external wake CLI, docs/turn-loop/mcp.md) and
# `hive-metric` (agent-emitted custom metrics CLI,
# docs/observability.md).
environment.systemPackages = [
config.hyperhive.packages.hive-agent-wake
config.hyperhive.packages.hive-metric
]
++ (with pkgs; [
claude-code
bashInteractive
coreutils-full
@ -180,7 +183,7 @@
jq
# curl: HTTP client for forge REST API and other web requests.
curl
];
]);
# HIVE_ASSETS_DIR points at the project's static runtime assets
# (branding + claude prompts; see `nix/packages/assets.nix`). Set
@ -191,7 +194,7 @@
# host-level `services.hyperhive.c0re.contextWindowTokens` option — not
# set here.
environment.variables = {
HIVE_ASSETS_DIR = "${pkgs.hyperhive-assets}/share/hyperhive";
HIVE_ASSETS_DIR = "${config.hyperhive.packages.assets}/share/hyperhive";
SHELL = "${pkgs.bashInteractive}/bin/bash";
# Route interactive-shell nix invocations through the host daemon.
# Redundant with /etc/profile.d/nix-daemon.sh but ensures it's set

View file

@ -21,12 +21,12 @@
options.hyperhive.docs.source = lib.mkOption {
type = lib.types.path;
default = pkgs.hyperhive-docs;
defaultText = lib.literalMD "`pkgs.hyperhive-docs` (built from the repo `docs/` tree)";
default = config.hyperhive.packages.reference-docs;
defaultText = lib.literalMD "`hyperhive.packages.reference-docs` (built from the repo `docs/` tree)";
description = ''
Store path of the reference-docs tree exposed at `$HIVE_DOCS_DIR`
when `hyperhive.docs.enable` is set. Defaults to
`pkgs.hyperhive-docs` (the `nix/packages/reference-docs.nix`
when `hyperhive.docs.enable` is set. Defaults to the flake's
`reference-docs` package (the `nix/packages/reference-docs.nix`
build) so a standalone container build from a full checkout
works unchanged. The generated meta flake overrides this with the
narrow `hyperhive-docs` flake input so a doc edit only

View file

@ -45,8 +45,9 @@ in
# claude can `tea repos create`, `tea pulls create`, etc.
pkgs.tea
# hive-forge <verb>: CLI wrapping common Forgejo REST API operations
# (view, pr, issue, comment, assign, close, labels, branches, etc.)
(pkgs.callPackage ../../packages/hive-forge-tools.nix { })
# (view, pr, issue, comment, assign, close, labels, branches, etc.).
# The per-bin split package — narrow closure, no hivectl/wireguard.
config.hyperhive.packages.hive-forge
];
# One-shot: tea config.yml from the seeded forge token. Shape

View file

@ -10,8 +10,8 @@
{
options.hyperhive.frontend.dist = lib.mkOption {
type = lib.types.package;
default = pkgs.hyperhive-frontend;
defaultText = lib.literalExpression "pkgs.hyperhive-frontend";
default = config.hyperhive.packages.frontend;
defaultText = lib.literalMD "`hyperhive.packages.frontend` (the flake's frontend dist)";
description = ''
The shipped frontend dist (built by `nix/packages/frontend.nix`).
Output layout: `dashboard/` (used by hive-c0re on the host) and

View file

@ -195,7 +195,7 @@ in
# can override the entry.
hyperhive.extraMcpServers = lib.mkIf config.hyperhive.matrix.enable {
matrix = lib.mkDefault {
command = "${pkgs.hive-matrix-mcp}/bin/hive-matrix-mcp";
command = "${config.hyperhive.packages.hive-matrix-mcp}/bin/hive-matrix-mcp";
args = [ ];
# Same socket path the hive-matrix-daemon service binds
# via its `RuntimeDirectory = "hive-matrix"`. Keeps the
@ -259,7 +259,7 @@ in
HIVE_ICON_PNG = "${iconPng}";
};
serviceConfig = {
ExecStart = "${pkgs.hive-matrix-daemon}/bin/hive-matrix-daemon";
ExecStart = "${config.hyperhive.packages.hive-matrix-daemon}/bin/hive-matrix-daemon";
SyslogIdentifier = "hive-matrix-daemon";
Restart = "on-failure";
RestartSec = 5;

View file

@ -159,7 +159,7 @@ in
# agent.nix can override the entry. (The matrix sibling lives in
# ./matrix.nix, gated on hyperhive.matrix.enable.)
hyperhive.extraMcpServers.bash = lib.mkDefault {
command = "${pkgs.hive-bash-mcp}/bin/hive-bash-mcp";
command = "${config.hyperhive.packages.hive-bash-mcp}/bin/hive-bash-mcp";
args = [ ];
env.HIVE_BASH_SOCKET = "/run/hive-bash/socket";
allowedTools = [ "*" ];
@ -203,7 +203,7 @@ in
# value but is less robust if the two vars ever diverge.
};
serviceConfig = {
ExecStart = "${pkgs.hive-bash-daemon}/bin/hive-bash-daemon";
ExecStart = "${config.hyperhive.packages.hive-bash-daemon}/bin/hive-bash-daemon";
SyslogIdentifier = "hive-bash-daemon";
Restart = "on-failure";
RestartSec = 3;
@ -239,7 +239,7 @@ in
before = [ "hive-ag3nt.service" ];
environment.RUST_LOG = "info";
serviceConfig = {
ExecStart = "${pkgs.hive-agent-mcp}/bin/hive-agent-mcp --http 127.0.0.1:${toString config.hyperhive.mcp.httpPort}";
ExecStart = "${config.hyperhive.packages.hive-agent-mcp}/bin/hive-agent-mcp --http 127.0.0.1:${toString config.hyperhive.mcp.httpPort}";
SyslogIdentifier = "hive-mcp-http";
# `always` (not `on-failure`): this endpoint is load-bearing — the
# sole hyperhive-MCP transport, so a down window is total

View file

@ -0,0 +1,22 @@
# The hyperhive-built packages the harness modules consume, threaded
# in explicitly as an option — no overlay. The flake's
# `nixosModules.{agent-base,ruth}` set this to the flake's own package
# outputs via `lib.mkDefault`, so a per-agent override of an
# individual key still wins.
{ lib, ... }:
{
options.hyperhive.packages = lib.mkOption {
type = lib.types.attrsOf lib.types.package;
internal = true;
description = ''
hyperhive package outputs consumed by the harness modules: the
per-binary daemon/CLI packages (`hive-agent`, `hive-agent-mcp`,
`hive-agent-wake`, `hive-bash-daemon`, `hive-bash-mcp`,
`hive-forge`, `hive-matrix-daemon`, `hive-matrix-mcp`,
`hive-metric`) plus the `assets`, `frontend` and
`reference-docs` trees. Wired by the flake's agent-base/ruth
nixosModules to `hyperhive.packages.<system>.*`; override an
individual key per-agent to swap in a patched binary.
'';
};
}