Watch
0
0
Fork
You've already forked hyperhive
0

agent: pull in and allow claude-code only for the claude runtime

This commit is contained in:
atlas 2026-11-04 20:52:49 +01:00
commit 1ce5996c49
3 changed files with 30 additions and 6 deletions

View file

@ -39,8 +39,9 @@ nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
}; };
``` ```
`claude-code` is unfree. Hyperhive scopes the allowance to itself, so you `claude-code` is unfree. Hyperhive scopes the allowance to itself, and only
don't set `allowUnfree`. for agents that run claude (`services.hyperhive.agent.runtime = "claude"`, the
default), so you don't set `allowUnfree`.
## 3 · Set the required options ## 3 · Set the required options

View file

@ -41,6 +41,10 @@ let
queue option. Remove the setting. queue option. Remove the setting.
''; '';
# Only a claude-runtime agent runs the binary. ACP subagents run on the
# parent agent's runtime, so they need no claude either.
runsClaude = config.services.hyperhive.agent.runtime == "claude";
# `claude` on PATH. A hive that pins a claude-code # `claude` on PATH. A hive that pins a claude-code
# (`services.hyperhive.deploy.hive-controller.claudeCodePackage`) hands its # (`services.hyperhive.deploy.hive-controller.claudeCodePackage`) hands its
# store path over at container start as `HYPERHIVE_CLAUDE_CODE_PATH`, and # store path over at container start as `HYPERHIVE_CLAUDE_CODE_PATH`, and
@ -237,7 +241,10 @@ in
# evaluates its own `nixpkgs` instance, so the operator's host-level # evaluates its own `nixpkgs` instance, so the operator's host-level
# `nixpkgs.config.allowUnfreePredicate` does not propagate into here — # `nixpkgs.config.allowUnfreePredicate` does not propagate into here —
# we have to allow it inside the container's config as well. # we have to allow it inside the container's config as well.
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [ "claude-code" ]; # Only an agent that runs claude needs it: `runtime = "acp"` never
# references the package, so it is neither built nor allowed there.
nixpkgs.config.allowUnfreePredicate =
pkg: runsClaude && builtins.elem (pkgs.lib.getName pkg) [ "claude-code" ];
# Core tooling every agent gets. Per-bin split packages (see # Core tooling every agent gets. Per-bin split packages (see
# nix/packages/default.nix + ./packages.nix) rather than the full # nix/packages/default.nix + ./packages.nix) rather than the full
@ -256,9 +263,7 @@ in
environment.systemPackages = [ environment.systemPackages = [
config.services.hyperhive.agent.packages.hive-metric config.services.hyperhive.agent.packages.hive-metric
] ]
++ [ ++ lib.optional runsClaude claude
claude
]
++ (with pkgs; [ ++ (with pkgs; [
bashInteractive bashInteractive
coreutils-full coreutils-full

View file

@ -83,6 +83,9 @@ let
}; };
}; };
hasClaude = machine: lib.any (p: (p.name or "") == "claude") machine.environment.systemPackages;
allowsClaudeCode = machine: machine.nixpkgs.config.allowUnfreePredicate { pname = "claude-code"; };
subagent = machine: machine.systemd.services.hive-subagent-daemon; subagent = machine: machine.systemd.services.hive-subagent-daemon;
harness = machine: machine.systemd.services.hive-agent; harness = machine: machine.systemd.services.hive-agent;
runtimeVars = [ runtimeVars = [
@ -234,6 +237,21 @@ let
&& !(lib.hasInfix "rm -f \"$earlier\"" s) && !(lib.hasInfix "rm -f \"$earlier\"" s)
&& !(lib.hasInfix "mv -f \"$staged\" \"$earlier\"" s); && !(lib.hasInfix "mv -f \"$staged\" \"$earlier\"" s);
} }
{
name = "an ACP agent has no claude on PATH and no unfree allowance for claude-code";
ok = !(hasClaude acp) && !(allowsClaudeCode acp) && !(allowsClaudeCode opencode);
}
{
# Presence control for the case above: the same lookups find both on a
# claude agent, and the allowance is for claude-code alone.
name = "a claude agent has claude on PATH and an unfree allowance for claude-code only";
ok =
hasClaude claude
&& hasClaude claudeApiKey
&& allowsClaudeCode claude
&& allowsClaudeCode claudeApiKey
&& !(claude.nixpkgs.config.allowUnfreePredicate { pname = "other-unfree"; });
}
]; ];
in in
runGroup "agent-runtime" cases runGroup "agent-runtime" cases