hive-forge: require HIVE_FORGE_URL, give agent login shells the forge env
This commit is contained in:
parent
aecde1dc75
commit
4440d8fb29
1 changed files with 171 additions and 87 deletions
37
hive-meta-flake/testdata/meta-flake.nix.in
vendored
37
hive-meta-flake/testdata/meta-flake.nix.in
vendored
|
|
@ -21,6 +21,14 @@
|
|||
).hyperhiveArchetypes.${archetype.name}.module
|
||||
or (throw "agent ${name}: this hive's ${archetype.source} input has no archetype ${archetype.name}; update that input");
|
||||
service = "hive-agent";
|
||||
# One attrset for `environment.variables` (login shells),
|
||||
# `systemd.globalEnvironment` (every unit) and the harness service,
|
||||
# so the three cannot disagree. The forwarded vars come from the host.
|
||||
agentEnv = {
|
||||
HIVE_LABEL = name;
|
||||
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||
HYPERHIVE_HARNESS_DIR = "/agents/${name}/harness";
|
||||
};
|
||||
in
|
||||
base.extendModules {
|
||||
modules = [
|
||||
|
|
@ -46,28 +54,15 @@
|
|||
name = name;
|
||||
email = "${name}@hyperhive.local";
|
||||
};
|
||||
# Container-wide env: every service + co-process daemon can
|
||||
# resolve the agent's durable state dir without hard-coding it.
|
||||
# `environment.variables` only writes /etc/environment (login
|
||||
# shells); `systemd.globalEnvironment` is the analogue for
|
||||
# systemd units so forge-avatar-sync /
|
||||
# hive-matrix-daemon etc. can read `$HYPERHIVE_STATE_DIR`
|
||||
# without each service having to redeclare it.
|
||||
environment.variables = {
|
||||
HIVE_LABEL = name;
|
||||
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||
HYPERHIVE_HARNESS_DIR = "/agents/${name}/harness";
|
||||
};
|
||||
systemd.globalEnvironment = {
|
||||
HIVE_LABEL = name;
|
||||
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||
HYPERHIVE_HARNESS_DIR = "/agents/${name}/harness";
|
||||
};
|
||||
systemd.services.${service}.environment = {
|
||||
# Container-wide env, all from `agentEnv`: every unit and daemon
|
||||
# (the bash-task runner where `hive-forge` and `git` run included)
|
||||
# resolves the state dir and the forwarded service URLs without
|
||||
# redeclaring them. `environment.variables` is what login shells
|
||||
# read; `systemd.globalEnvironment` is the analogue for units.
|
||||
environment.variables = agentEnv;
|
||||
systemd.globalEnvironment = agentEnv;
|
||||
systemd.services.${service}.environment = agentEnv // {
|
||||
HIVE_PORT = toString port;
|
||||
HIVE_LABEL = name;
|
||||
HYPERHIVE_STATE_DIR = "/agents/${name}/state";
|
||||
HYPERHIVE_HARNESS_DIR = "/agents/${name}/harness";
|
||||
};
|
||||
}
|
||||
# Tells the harness the agent has no config repo of its own.
|
||||
|
|
|
|||
Loading…
Reference in a new issue