nixos/palace: Run slop-broker for agents

`slop-cannon`'s agents reach the broker on `palace` through a vsock
device, under an `agent` policy: box queries run without asking,
`slop ssh` asks (offering 5 min and 1 h leases), and so do deploys.
The deploy key moves to `palace` as an age secret for the broker, so
the VM never holds it, and `AGENTS.md` points agents there at `slop`.

`palace` runs the builder itself, as `slop-broker-build`, reached over
SSH like a separate box and fetching `dev/nixfiles` with a read-only
deploy key, so `slop-cannon` shrinks to 24 GiB. `slop build` pushes
into Harmonia's store on `object` with a key of the broker's own,
which can only speak the store protocol and add GC roots there.
Agents' use of the builder asks, unless the commit is already on
`master`. Builds run agent-written Nix, so they only reach the
Internet, like `lan-untrusted`, and `nix-daemon` is limited so they
can't starve the VMs.

The approvals web app listens on `palace` for `middleman` only, the
one client the firewall lets in, which publishes it at
`approve.slop.nul.ie`. Approvers sign in with Pocket ID, and deploys
to the routers need a fresh passkey.

The broker's SSH targets are the deploy-rs nodes on `master`, which
the builder reads there, so agents can't add or redirect one.

With the broker gating what needs credentials, `slop-cannon`'s agents
are permissive by default: Claude bypasses permission prompts and
Codex runs without approvals or its sandbox, with matching Paseo
profiles. The deny rules for raw `deploy` and `ssh-machine` stay as
steers towards `slop`; the ones for `.keys/` go, since the VM's
checkout only has the committed public keys there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jackos1998andClaude Opus 5.5 committed 2026-11-24 23:45:27 +00:00
1 parent 71ed076f12
commit 2519c3c86c
17 files changed
+416 -35

No files matched your search

@@ -416,6 +416,15 @@ in
useACMEHost = pubDomain;
};
# `slop-broker`'s approvals web app, which handles sign-in itself
"approve.slop.${pubDomain}" = {
locations."/" = {
proxyPass = "http://palace.${home.domain}:8095";
extraConfig = proxyHeaders;
};
useACMEHost = pubDomain;
};
"id.${pubDomain}" =
let
pocketId = {
@@ -183,6 +183,18 @@ in
environment.systemPackages = [ minioPkgs.minio-client ];
services = {
# `slop build` on `palace` pushes into Harmonia's store
slop-broker-cache = {
enable = true;
user = "harmonia";
store = "/var/lib/harmonia";
# As `ci/push-to-cache.sh` does; `harmonia-dev`'s runtime directory
home = "/run/harmonia";
brokerKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJMx9rrKaPGFnwdvdEKCHyonMjWi/kDWMkbZkSEHijhp slop-broker cache (palace)"
];
};
atticd = {
enable = false;
environmentFile = config.age.secrets."object/atticd.env".path;
+1 -1
View File
@@ -5,7 +5,7 @@ let
inherit (lib.my.c.home) domain vlans prefixes vips vlanDns hiMTU;
in
{
imports = [ ./vms ];
imports = [ ./slop-broker.nix ./vms ];
nixos.systems.palace = {
system = "x86_64-linux";
+150
View File
@@ -0,0 +1,150 @@
{
nixos.systems.palace.configuration = { lib, config, allAssignments, ... }:
let
# `slop-cannon`'s vsock address; the kernel reports it for every connection from the guest
slopCannonCid = 3;
# Home's pair, and colony's
routers = [ "river" "stream" "estuary" ];
middleman = allAssignments.middleman.internal;
webPort = config.services.slop-broker.web.port;
in
{
my = {
secrets.files = {
"palace/slop-broker-deploy.key" = {
owner = "root";
mode = "0400";
};
# Pushes `slop build` outputs into Harmonia's store on `object`
"palace/slop-broker-cache.key" = {
owner = "root";
mode = "0400";
};
# The approvals web app's client secret at Pocket ID
"palace/slop-broker-oidc-secret" = {
owner = "root";
mode = "0400";
};
# Read-only deploy key for `dev/nixfiles` on Gitea
"palace/slop-broker-git.key" = {
owner = "slop-broker-build";
group = "slop-broker-build";
mode = "0400";
};
};
vms.instances.slop-cannon.qemuFlags = [ "device vhost-vsock-pci,guest-cid=${toString slopCannonCid}" ];
# Builds and the builder run agent-written Nix, so like `lan-untrusted` they only get the
# Internet (and `resolved`'s stub, which builds use for DNS)
firewall.extraRules = ''
table inet filter {
chain agent-builds {
ct state established,related return
ip daddr 127.0.0.53 meta l4proto { tcp, udp } th dport 53 return
${lib.my.c.internalNets.nftReject}
}
chain output {
meta skgid ${toString config.ids.gids.nixbld} jump agent-builds
meta skuid slop-broker-build jump agent-builds
}
# Only `middleman`, which publishes it, may reach the web app; `input` (not `wan-tcp`, which
# ends in `return`) gets these after everything else
chain input {
ip saddr ${middleman.ipv4.address} tcp dport ${toString webPort} accept
ip6 saddr ${middleman.ipv6.address} tcp dport ${toString webPort} accept
}
}
'';
};
# Builds commits for `slop deploy` and `slop build`, as a user without keys; reached over SSH
# like a separate box
services.slop-broker-builder = {
enable = true;
repository = "git@git.nul.ie:dev/nixfiles.git";
keyFile = config.age.secrets."palace/slop-broker-git.key".path;
brokerKeys = [ (lib.trim (builtins.readFile lib.my.c.sshKeyFiles.deploy)) ];
};
services.slop-broker = {
enable = true;
approvers = [ config.my.user.config.name ];
# For coding agents, wherever they run
policies.agent.ops = {
# Fixed read-only commands built by the broker
query.action = "auto";
# Running agent-written Nix at all; approvers see the commits and diff. Commits already
# on `master` have been reviewed.
builder = {
action = "ask";
leases = [ "1h" ];
rules = [
{
match.on_branch = "true";
action = "auto";
}
];
};
deploy = {
action = "ask";
# The routers carry everything else; a bad deploy there is hard to reach and undo
rules = map
(node: {
match.node = node;
action = "ask";
confirm = "passkey";
})
routers;
};
# The source was reviewed for `builder`, and the cache only gets what `palace` built
build.action = "auto";
ssh = {
action = "ask";
leases = [ "5m" "1h" ];
};
};
requesters.slop-cannon = {
vsockCid = slopCannonCid;
policy = "agent";
};
ssh = {
enable = true;
keyFile = config.age.secrets."palace/slop-broker-deploy.key".path;
};
deploy.enable = true;
cache = {
enable = true;
hostname = "object-ctr.${lib.my.c.colony.domain}";
user = "harmonia";
keyFile = config.age.secrets."palace/slop-broker-cache.key".path;
};
# `approve.slop.nul.ie`, published by `middleman`; approvers sign in with Pocket ID
web = {
enable = true;
address = "::";
url = "https://approve.slop.${lib.my.c.pubDomain}";
issuer = "https://id.${lib.my.c.pubDomain}";
clientSecretFile = config.age.secrets."palace/slop-broker-oidc-secret".path;
};
};
# The ruleset check runs where `slop-broker-build` doesn't exist
networking.nftables.preCheckRuleset = ''
sed 's/skuid slop-broker-build/skuid nobody/g' -i ruleset.conf
'';
# Builds share the host with the VMs, including the router; keep them from starving those
systemd.services.nix-daemon.serviceConfig = {
MemoryHigh = "32G";
MemoryMax = "40G";
CPUWeight = 20;
};
};
}
+1 -1
View File
@@ -272,7 +272,7 @@
cpus = 16;
threads = 2;
};
memory = 49152;
memory = 24576;
cleanShutdown.timeout = 120;
drives = [
installerDisk
+29 -17
View File
@@ -35,17 +35,14 @@ in
giteaKey = config.age.secrets."slop-cannon/gitea-key".path;
paseoPasswordFile = config.age.secrets."slop-cannon/paseo.env".path;
# Steer agents to the approval broker; these match command text, so they aren't a boundary
# Steer agents to the approval broker; these match command text, so they aren't a boundary.
# `.keys/` only has the committed public keys here, which agents may read.
claudeDeny = [
"Bash(deploy:*)"
"Bash(ssh-machine:*)"
"Read(**/.keys/**)"
"Edit(**/.keys/**)"
];
claudeAsk = [
"Bash(slop-deploy:*)"
"Bash(slop-ssh:*)"
];
# The broker asks a human where policy says so; a second prompt here would only add noise
claudeAllow = [ "Bash(slop:*)" ];
slopClone = pkgs.writeShellApplication {
name = "slop-clone";
@@ -192,16 +189,26 @@ in
};
home-manager.users.${agentUser} = {
my.agents.enable = true;
my.agents = {
enable = true;
slop.enable = true;
};
home.packages = [ slopClone slopPair ];
programs = {
# Permissive by default: the VM is the boundary, and `slop-broker` gates what needs
# credentials
claude-code.settings.permissions = {
defaultMode = "bypassPermissions";
allow = claudeAllow;
deny = claudeDeny;
ask = claudeAsk;
};
codex.settings.cli_auth_credentials_store = "file";
codex.settings = {
cli_auth_credentials_store = "file";
approval_policy = "never";
sandbox_mode = "danger-full-access";
};
# The shared config pins `IdentityFile` for every host
ssh.settings."git.nul.ie" = {
@@ -212,10 +219,7 @@ in
# Not editable by the agent user without `doas`; a convenience, not a boundary
environment.etc."claude-code/managed-settings.json".text = toJSON {
permissions = {
disableBypassPermissionsMode = "disable";
deny = claudeDeny;
};
permissions.deny = claudeDeny;
};
systemd = {
@@ -281,12 +285,20 @@ in
# Keep agents from changing modes, answering prompts or opening terminals
mcp.injectIntoAgents = false;
relay.requireProtectedSecurity = true;
# Paseo can't change a provider's default mode, only offer these; `slop-broker` gates
# what needs credentials
agentProfiles = [
{
id = "claude-accept-edits";
name = "Claude, accept edits";
id = "claude-bypass";
name = "Claude, bypass permissions";
provider = "claude";
modeId = "acceptEdits";
modeId = "bypassPermissions";
}
{
id = "codex-full-access";
name = "Codex, full access";
provider = "codex";
modeId = "full-access";
}
];
};