Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/nix/module-eval/agent-icon.nix
iris 1a31a4cd5a swarm: set an agent's config repo avatar from its icon
The agent module exposes the PNG nix renders from the agent's icon as the
read-only option services.hyperhive.agent.iconPng, which the forge and matrix
avatar syncs now share. When the builder reads an icon it builds that one
attribute with nix build and sends the file, base64, next to the SVG in the
meta build reply, so the builder runs no renderer of its own.

After recording the icon, the controller sets the avatar of
agent-configs/<agent> from the PNG as the forge admin, removes the avatar when
the icon is removed, and leaves it alone when the builder sent no PNG. A marker
per repo holds the image's fingerprint, so a build whose icon did not change
makes no forge call; a forge that refuses the avatar does not fail the build.
An old builder sends no PNG, so it changes nothing.
2026-11-23 10:11:16 +01:00

59 lines
2.2 KiB
Nix

# `checks.module-eval-agent-icon` — see ./lib.nix for the shared
# rationale (why this suite exists, naming convention, "evaluates
# not executes").
{
pkgs,
lib,
self,
nixosSystem,
}:
let
inherit
(import ./lib.nix {
inherit
pkgs
lib
self
nixosSystem
;
})
agent
agentWith
runGroup
;
# An agent with an icon and no forge. Both halves of the avatar sync — the
# `.path` watcher and the oneshot it triggers — hang off the icon, but only
# the service can do anything with a forge URL, so the icon alone is the one
# input that can render half the feature. `pkgs.emptyFile` rather than a real
# SVG: the icon is only ever a gate here, and nothing this case reads
# rasterizes it.
agentIconNoForge = agentWith { services.hyperhive.agent.icon = pkgs.emptyFile; };
agentNoIcon = agentWith { };
cases = [
{
# The builder builds this option and sends the PNG to the controller for
# the config repo's avatar, so it must be a derivation when an icon is set
# and null when none is (the builder skips the build then).
name = "iconPng is the rasterized icon, and null without one";
ok =
lib.isDerivation agentIconNoForge.services.hyperhive.agent.iconPng
&& agentNoIcon.services.hyperhive.agent.iconPng == null;
}
{
# The absence class, and a gate asymmetry nothing else can see. A `.path`
# unit is `wantedBy = multi-user.target` and names a `Unit=` by
# convention rather than by reference, so one gated more loosely than the
# service it triggers evaluates clean, deploys clean, and then fails to
# activate the first time the watched file is written. `forge.url`'s own
# option doc already promises the avatar-sync units are "not generated at
# all" without a forge — this is the case that makes that sentence true
# of the watcher and not only of the oneshot.
name = "an agent with an icon and no forge renders neither avatar-sync unit";
ok =
!(agentIconNoForge.systemd.paths ? forge-avatar-sync)
&& !(agentIconNoForge.systemd.services ? forge-avatar-sync);
}
];
in
runGroup "agent-icon" cases