Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/nix/archetypes/default.nix
maia c9204ad0e0 android-dev archetype: ship the Android SDK and nix-ld so a Gradle build runs
The archetype installed Gradle, a JDK and android-tools but no SDK, no
ANDROID_HOME/JAVA_HOME and no nix-ld, so the aapt2 Gradle downloads could not
start on NixOS and an agent could not build an app.

It now builds an SDK (build-tools 36.1.0, platform 35, no emulator or system
images), sets ANDROID_HOME, ANDROID_SDK_ROOT and JAVA_HOME, and enables
programs.nix-ld. The SDK's unfree names are read off the SDK and added to
allowUnfreePackages, which adds to the claude-code allowance instead of
replacing it.

Closes #6696
2026-11-20 19:35:47 +01:00

216 lines
7.8 KiB
Nix

# The archetypes this flake ships, exposed as `hyperhiveArchetypes`. Each is
# `{ module; meta; }`: `module` is a NixOS module for the agent's container,
# `meta` is plain data (no derivations, no `pkgs`), because the swarm
# builder evaluates `meta` alone and swarm-controller stores it as JSON.
# `meta` fields: `description` (required), `permissions`, `limits`,
# `inference`, in the shapes `POST /api/agents` takes them, `icon`, the SVG text
# the create form shows beside the archetype, and `prompt`, the text the create
# form prefills the new agent's AGENTS.md with (the built-ins read theirs from
# ./prompts/<name>.md); see docs/2-handbook/swarm/archetypes.md. Every archetype
# sets `services.hyperhive.agent.icon` (with `mkDefault`) to an SVG in `icons/`,
# so its agents show one until their config sets another.
{
reviewer = {
module =
{ lib, ... }:
{
services.hyperhive.agent.icon = lib.mkDefault ./icons/reviewer.svg;
};
meta = {
icon = builtins.readFile ./icons/reviewer.svg;
description = "Reviews pull requests and replies. It can run hive-forge and git (execution), and holds messaging and inbox; it has no get_agent_meta (meta).";
permissions = [
"messaging"
"inbox"
"execution"
];
prompt = builtins.readFile ./prompts/reviewer.md;
};
};
android-dev = {
module =
{ pkgs, lib, ... }:
let
# build-tools 36.1.0 and platform 35: the pair the damocles agent builds
# with. No emulator and no system images; they are large, and a build
# is run against a device or an emulator elsewhere.
sdk = pkgs.androidenv.composeAndroidPackages {
buildToolsVersions = [ "36.1.0" ];
platformVersions = [ "35" ];
includeEmulator = false;
includeSystemImages = false;
};
sdkRoot = "${sdk.androidsdk}/libexec/android-sdk";
# The unfree names the SDK needs: each package it is built from and
# the archives those fetch. Read off the SDK itself, because the
# archive names carry versions that change with every nixpkgs bump.
asDrvs =
v:
if lib.isDerivation v then
[ v ]
else if lib.isList v then
lib.concatMap asDrvs v
else
[ ];
sdkParts = lib.concatMap asDrvs (lib.attrValues (removeAttrs sdk [ "recurseForDerivations" ]));
sdkUnfree = lib.unique (
map lib.getName (lib.concatMap (part: [ part ] ++ asDrvs (part.src or [ ])) sdkParts)
);
in
{
services.hyperhive.agent.icon = lib.mkDefault ./icons/android-dev.svg;
environment.systemPackages = [
pkgs.android-tools
pkgs.gradle
pkgs.jdk
];
environment.variables = {
ANDROID_HOME = sdkRoot;
ANDROID_SDK_ROOT = sdkRoot;
JAVA_HOME = "${pkgs.jdk.home}";
};
# Gradle downloads and runs its own prebuilt `aapt2`, a foreign dynamic
# binary that NixOS cannot start without a loader at /lib64. nix-ld is
# that loader. Its default library set already carries the C++ runtime
# and zlib that the download links against, and the module-eval check
# asserts it still does.
programs.nix-ld.enable = true;
# The SDK packages are unfree and ask for their licence to be accepted.
# `allowUnfreePackages` adds to the claude-code allowance the agent
# modules set, where a second `allowUnfreePredicate` would replace it.
nixpkgs.config.android_sdk.accept_license = true;
nixpkgs.config.allowUnfreePackages = sdkUnfree;
};
meta = {
icon = builtins.readFile ./icons/android-dev.svg;
description = "Builds Android apps: adb and fastboot (android-tools), Gradle, a JDK, the Android SDK (build-tools 36.1.0, platform 35) and nix-ld, so Gradle's downloaded aapt2 runs. ANDROID_HOME and JAVA_HOME are set. It holds the default permissions.";
prompt = builtins.readFile ./prompts/android-dev.md;
};
};
reverse-engineer = {
module =
{ lib, ... }:
{
services.hyperhive.agent.icon = lib.mkDefault ./icons/reverse-engineer.svg;
services.hyperhive.agent.rea.enable = true;
};
meta = {
icon = builtins.readFile ./icons/reverse-engineer.svg;
description = "Reverse-engineers binaries and applications: REA and Ghidra 12.1 are installed with their MCP tools allowed. It holds the default permissions.";
prompt = builtins.readFile ./prompts/reverse-engineer.md;
};
};
ruth = {
module =
{ lib, ... }:
{
services.hyperhive.agent.icon = lib.mkDefault ./icons/ruth.svg;
};
meta = {
icon = builtins.readFile ./icons/ruth.svg;
description = "The manager agent the setup assistant creates. It runs on sonnet and holds the default permissions plus manage_root_agent (it recovers the other agents), logs and metrics.";
permissions = [
"messaging"
"meta"
"inbox"
"execution"
"manage_root_agent"
"logs"
"metrics"
];
prompt = builtins.readFile ./prompts/ruth.md;
inference = {
model = "sonnet";
};
};
};
triage =
let
# One flow per event and action; every todo goes to `members`, under a
# `forge:<repo>#<number>:` key so the built-in closed flow clears it.
newItem =
{
id,
name,
event,
action,
text,
}:
{
inherit id name;
nodes = [
{
id = "src";
kind = "source";
events = [ event ];
}
{
id = "action";
kind = "match";
when = [
{
field = "action";
equals = action;
}
];
}
{
id = "tell";
kind = "todo";
to = "members";
op = "upsert";
key = "forge:{{ repo }}#{{ number }}:triage-${action}";
inherit text;
}
];
edges = [
{
from = "src";
to = "action";
}
{
from = "action";
to = "tell";
}
];
};
in
{
module =
{ lib, ... }:
{
services.hyperhive.agent.icon = lib.mkDefault ./icons/triage.svg;
};
meta = {
icon = builtins.readFile ./icons/triage.svg;
description = "Labels and assigns every new issue and pull request, then routes it. It runs on haiku, holds the default permissions and wakes on router todos for new and reopened issues and new pull requests, not on forge subscriptions.";
prompt = builtins.readFile ./prompts/triage.md;
inference = {
model = "haiku";
};
flows = [
(newItem {
id = "issue-opened";
name = "new issues go to triage";
event = "issues";
action = "opened";
text = "{{ repo }}#{{ number }}: a new issue was created. make sure it's labeled and has a matching assignee.";
})
(newItem {
id = "issue-reopened";
name = "reopened issues go to triage";
event = "issues";
action = "reopened";
text = "{{ repo }}#{{ number }}: an issue was reopened. make sure it's labeled and has a matching assignee.";
})
(newItem {
id = "pr-opened";
name = "new pull requests go to triage";
event = "pull_request";
action = "opened";
text = "{{ repo }}#{{ number }}: a new pull request was created. make sure it's labeled and has a reviewer.";
})
];
};
};
}