matrix: make the hive-internal main account an ordinary matrixAccounts entry
`matrixAccounts` is meant to be the agent's full account list, but the hive-internal `main` account was outside it: the nix module emitted only the extras and `hive-matrix-daemon` prepended a `main` it synthesized from the per-agent paths, with the option schema forbidding the name outright. nix/agent-modules/matrix.nix now declares `main` itself, as an ordinary entry under `matrix.enable`, from the state-dir paths the module already used for its token path-watcher (now a shared `stateDir` binding) plus `matrix.url`. The whole set, `main` included, is serialized to HIVE_MATRIX_ACCOUNTS. accounts::configured therefore synthesizes `main` only when the parsed list carries none, and otherwise takes the declared one verbatim — hoisting it to index 0, since the daemon reads index 0 as the primary and nix serializes an attrset, so `main` sorts wherever its key falls. Declared xor synthesized: an agent whose harness predates this entry keeps working, a current one gets its own, and there is no arrangement where `main` is duplicated or missing. The reserved-name assertion is replaced rather than dropped: the name must now be legal (the module uses it), but `main`'s tokenFile stays pinned to `<state>/matrix-token`, since hive-c0re provisions the hive-internal token there and nowhere else — a retarget would evaluate fine and then never restore. The other two fields are mkDefault and free to override. Refs #4475
This commit is contained in:
parent
c7f6c33321
commit
c74249f371
4 changed files with 220 additions and 80 deletions
|
|
@ -69,17 +69,22 @@ room you haven't read yet.
|
|||
|
||||
## Multiple accounts
|
||||
|
||||
`services.hyperhive.agent.matrixAccounts` (declared in `agent.nix`) gives an agent
|
||||
*additional* matrix identities beyond the hive-internal one — for example an
|
||||
`services.hyperhive.agent.matrixAccounts` (declared in `agent.nix`) is
|
||||
the agent's full set of matrix identities — for example an
|
||||
external-facing account alongside the internal one. Each entry is
|
||||
keyed by account name and specifies `tokenFile` (bearer token,
|
||||
provisioned out-of-band; basename must start with `matrix-token`),
|
||||
`sessionDir` (per-account matrix-sdk sqlite state — crypto keys +
|
||||
cache), and an optional `homeserver` (defaults to
|
||||
`services.hyperhive.agent.matrix.url`). The hive-internal account is always named
|
||||
`main`, synthesized from `services.hyperhive.agent.matrix.url` + agent state — this
|
||||
option only declares extras, and `main` is a reserved key here.
|
||||
Requires `services.hyperhive.agent.matrix.enable = true`.
|
||||
`services.hyperhive.agent.matrix.url`). The hive-internal account is
|
||||
always named `main` and is always the primary; the matrix module
|
||||
declares it for you as an ordinary entry of this map, from
|
||||
`services.hyperhive.agent.matrix.url` + agent state, so what you add
|
||||
here are the *further* accounts. Its `tokenFile` is pinned to
|
||||
`<state>/matrix-token` (hive-c0re provisions it there), and the
|
||||
dashboard's link-account route refuses to create an account by that
|
||||
name. Declaring extras requires
|
||||
`services.hyperhive.agent.matrix.enable = true`.
|
||||
|
||||
Every matrix tool above takes an optional `account` parameter (a name
|
||||
from this map) to act as that identity instead of the primary one.
|
||||
|
|
|
|||
Loading…
Reference in a new issue