hyperhive/nix/templates/manager.nix
iris 892e034908 frontend: wire static-dir env var + per-agent extraFiles option
Phase 3 of #273. Container plumbing for the bundled frontend dist:

- flake.nix overlay: `pkgs.hyperhive-frontend` exposed for the
  agent / manager containers (mirrors the existing `pkgs.hyperhive`
  pattern); module argument `hyperhiveFrontend = system: self
  .packages.${system}.frontend` threads the package into the host
  hive-c0re module without forcing operators to apply the overlay
  on their host pkgs.

- `services.hive-c0re.frontend` option: pinned to the flake's
  frontend package by default, overridable for custom dashboard
  SPAs. The hive-c0re systemd service gets `HIVE_STATIC_DIR =
  ${cfg.frontend}/dashboard` — the Rust binary will pick it up
  in Phase 4.

- `hyperhive.frontend.dist` option: per-container, defaults to
  `pkgs.hyperhive-frontend`. Override to ship a fully custom
  agent SPA (advanced; the default + extraFiles flow handles the
  common 'add files' case).

- `hyperhive.frontend.extraFiles` option: attrsOf submodule
  (mirroring the `hyperhive.extraMcpServers` shape per damocles'
  request so existing #322-style assertions keep their grip).
  Each entry has `source` (path relative to agent.nix) and
  `target` (URL/disk prefix within the merged static tree,
  defaulting to the attribute name). Operator-named example:
  the bitburner agent drops `bitburner-dist` into
  `/bitburner/` alongside the default agent UI at `/`.

- `hyperhive.frontend.mergedDist` (readOnly): the runCommand
  derivation that composes `agent/` from the default dist plus
  every `extraFiles` entry. Aborts on overwrite so a filename
  collision becomes a build error rather than a silent dist swap.
  agent-base.nix + manager.nix set their respective systemd
  service `HIVE_STATIC_DIR` to this merged path.

Until Phase 4 lands, the env var is set but unused — the Rust
binaries still serve assets via `include_str!`. The cutover
happens in the next commit on this branch.

Refs #273.
2026-05-23 14:51:01 +02:00

43 lines
1.6 KiB
Nix

{ pkgs, config, ... }:
{
imports = [ ./harness-base.nix ];
# Manager auto-unsubscribes from repo watches and skips the subscription/
# participation firehose — only direct mentions, reviews, and assignments
# land in the inbox. Sub-agents default to keepSubscriptions=true and
# skipNotifyReasons=[].
hyperhive.forge.keepSubscriptions = false;
hyperhive.forge.skipNotifyReasons = [
"subscribed"
"participating"
];
# HIVE_PORT/HIVE_LABEL/gitconfig are also injected by the generated
# `applied/hm1nd/flake.nix` (see `lifecycle::setup_applied`); the values
# here are the base config so the container stays sensible if anyone
# ever evaluates `nixosConfigurations.manager` standalone.
systemd.services.hive-m1nd = {
description = "hive-m1nd manager harness";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
environment = {
HIVE_PORT = "8000";
HIVE_LABEL = "hm1nd";
SHELL = "${pkgs.bashInteractive}/bin/bash";
# Manager runs the same hive-m1nd harness binary that serves
# the per-agent web UI; point it at the merged agent static dist
# (same shape as for sub-agents).
HIVE_STATIC_DIR = "${config.hyperhive.frontend.mergedDist}";
};
# See note in agent-base.nix — `/run/current-system/sw` makes the
# harness service PATH track `environment.systemPackages` so anything
# an agent adds to its own `agent.nix` is visible without editing the
# service definition.
path = [ "/run/current-system/sw" ];
serviceConfig = {
ExecStart = "${pkgs.hyperhive}/bin/hive-m1nd serve";
Restart = "on-failure";
RestartSec = 2;
};
};
}