harness: unify hive-ag3nt + hive-m1nd into one binary picking role from HIVE_ROLE (#598)

This commit is contained in:
damocles 2026-05-31 03:21:06 +02:00
commit dcaf1838e1
6 changed files with 717 additions and 840 deletions

View file

@ -1240,7 +1240,12 @@ in
systemd.services.${if config.hyperhive.role == "manager" then "hive-m1nd" else "hive-ag3nt"} =
let
isManager = config.hyperhive.role == "manager";
binary = if isManager then "hive-m1nd" else "hive-ag3nt";
# Post-#598 there is exactly one harness binary (`hive`), and
# it picks its surface from `HIVE_ROLE` at startup. We still
# name the systemd unit `hive-ag3nt` / `hive-m1nd` so dashboard
# log queries + ExecStartPre paths + ancestor PR diffs keep
# working without a unit rename cascade.
binary = "hive";
in
{
description = "${binary}${lib.optionalString isManager " manager"} harness";
@ -1283,6 +1288,10 @@ in
# unit directly — `environment.variables` only populates
# /etc/profile, which systemd services don't inherit.
HIVE_ASSETS_DIR = "${pkgs.hyperhive-assets}/share/hyperhive";
# Post-#598: the unified `hive` binary picks its surface from
# this env var at startup. Default (`"agent"`) matches the
# binary's standalone fallback when this is unset.
HIVE_ROLE = config.hyperhive.role;
}
// lib.optionalAttrs isManager {
# Standalone-eval fallbacks for `nixosConfigurations.manager`.