`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>
320 lines
9.9 KiB
Nix
320 lines
9.9 KiB
Nix
{ lib, ... }:
|
|
let
|
|
inherit (lib.my) net;
|
|
inherit (lib.my.c.home) domain prefixes vips;
|
|
in
|
|
{
|
|
nixos.systems.slop-cannon = {
|
|
system = "x86_64-linux";
|
|
nixpkgs = "mine";
|
|
home-manager = "mine";
|
|
|
|
# The routers limit traffic from the untrusted VLAN to the Internet
|
|
assignments.untrusted = {
|
|
inherit domain;
|
|
mtu = prefixes.untrusted.mtu;
|
|
ipv4 = {
|
|
address = net.cidr.host 5 prefixes.untrusted.v4;
|
|
mask = 24;
|
|
gateway = vips.untrusted.v4;
|
|
};
|
|
ipv6 = {
|
|
iid = "::5";
|
|
address = net.cidr.host 5 prefixes.untrusted.v6;
|
|
};
|
|
};
|
|
|
|
configuration = { lib, modulesPath, config, pkgs, assignments, ... }:
|
|
let
|
|
inherit (builtins) toJSON;
|
|
inherit (lib) mkMerge;
|
|
inherit (lib.my) networkdAssignment;
|
|
|
|
agentUser = "slop-cannon";
|
|
agentHome = "/home/${agentUser}";
|
|
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.
|
|
# `.keys/` only has the committed public keys here, which agents may read.
|
|
claudeDeny = [
|
|
"Bash(deploy:*)"
|
|
"Bash(ssh-machine:*)"
|
|
];
|
|
# 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";
|
|
runtimeInputs = with pkgs; [ jujutsu openssh paseo ];
|
|
text = ''
|
|
if [ $# -ne 1 ] || [[ "$1" != */* ]]; then
|
|
echo "usage: slop-clone <owner>/<repo>" >&2
|
|
exit 1
|
|
fi
|
|
repo="$1"
|
|
dest="$HOME/src/''${repo##*/}"
|
|
|
|
if ! jj git clone --colocate "git@git.nul.ie:$repo.git" "$dest"; then
|
|
echo >&2
|
|
echo "Clone failed. If Gitea refused the key, add it as a write-enabled deploy key on $repo:" >&2
|
|
ssh-keygen -y -f ${giteaKey} >&2
|
|
exit 1
|
|
fi
|
|
|
|
paseo workspace create --isolation local --path "$dest"
|
|
'';
|
|
};
|
|
|
|
slopPair = pkgs.writeShellApplication {
|
|
name = "slop-pair";
|
|
runtimeInputs = [ pkgs.paseo ];
|
|
text = ''
|
|
if [ "$#" -ne 0 ]; then
|
|
echo "usage: slop-pair" >&2
|
|
exit 2
|
|
fi
|
|
|
|
paseo daemon pair
|
|
printf '\n'
|
|
exec doas ${pkgs.coreutils}/bin/cat ${paseoPasswordFile}
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
imports = [
|
|
"${modulesPath}/profiles/qemu-guest.nix"
|
|
];
|
|
|
|
config = {
|
|
boot = {
|
|
# Load the passed-through ConnectX VF even when PCI probing doesn't autoload it.
|
|
kernelModules = [ "kvm-amd" "mlx5_core" ];
|
|
kernelParams = [ "console=ttyS0,115200n8" ];
|
|
initrd = {
|
|
availableKernelModules = [ "virtio_pci" "ahci" "sr_mod" "virtio_blk" ];
|
|
kernelModules = [ "dm-snapshot" ];
|
|
};
|
|
# On disk rather than in the tmpfs root, so agents' scratch files don't use RAM
|
|
tmp.cleanOnBoot = true;
|
|
};
|
|
|
|
hardware = {
|
|
enableRedistributableFirmware = true;
|
|
};
|
|
|
|
fileSystems = {
|
|
"/boot" = {
|
|
device = "/dev/disk/by-partlabel/esp";
|
|
fsType = "vfat";
|
|
};
|
|
"/nix" = {
|
|
device = "/dev/main/slop-cannon-nix";
|
|
fsType = "ext4";
|
|
};
|
|
"/persist" = {
|
|
device = "/dev/main/slop-cannon-persist";
|
|
fsType = "ext4";
|
|
neededForBoot = true;
|
|
};
|
|
"/tmp" = {
|
|
device = "/dev/main/slop-cannon-tmp";
|
|
fsType = "ext4";
|
|
# Return deleted scratch space to the thin pool straight away
|
|
options = [ "discard" ];
|
|
};
|
|
};
|
|
|
|
networking = { inherit domain; };
|
|
|
|
services = {
|
|
# The LVs are thin, so space moves between them as needed
|
|
lvm = {
|
|
boot.thin.enable = true;
|
|
dmeventd.enable = true;
|
|
};
|
|
fstrim.enable = true;
|
|
};
|
|
|
|
# Grow the pool into the VG's spare space before it fills
|
|
environment.etc."lvm/lvm.conf".text = ''
|
|
activation/thin_pool_autoextend_threshold = 80
|
|
activation/thin_pool_autoextend_percent = 10
|
|
'';
|
|
|
|
my = {
|
|
server.enable = true;
|
|
|
|
# Root inside this VM belongs to the agents, so it gets no shared secrets: in particular
|
|
# not `user-passwd.txt`
|
|
user = {
|
|
passwordSecret = null;
|
|
config = {
|
|
password = null;
|
|
hashedPassword = "!";
|
|
};
|
|
};
|
|
|
|
secrets = {
|
|
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBCkgBZh/YejY+gDnGa9r5SPo1+aHWPAAAIfENE7t0Om";
|
|
files = {
|
|
"slop-cannon/gitea-key".owner = agentUser;
|
|
# `PASEO_PASSWORD=...`
|
|
"slop-cannon/paseo.env" = { };
|
|
};
|
|
};
|
|
|
|
tmproot.persistence.config.directories = [
|
|
{
|
|
directory = agentHome;
|
|
user = agentUser;
|
|
group = agentUser;
|
|
mode = "0700";
|
|
}
|
|
];
|
|
};
|
|
|
|
users = with lib.my.c.ids; {
|
|
groups.${agentUser}.gid = gids.slop-cannon;
|
|
users.${agentUser} = {
|
|
isNormalUser = true;
|
|
uid = uids.slop-cannon;
|
|
group = agentUser;
|
|
# Agents get root (passwordless `doas`) and can run nested VMs
|
|
extraGroups = [ "wheel" "kvm" ];
|
|
hashedPassword = "!";
|
|
shell = pkgs.fish;
|
|
openssh.authorizedKeys.keyFiles = [ lib.my.c.sshKeyFiles.me ];
|
|
};
|
|
};
|
|
|
|
home-manager.users.${agentUser} = {
|
|
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;
|
|
};
|
|
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" = {
|
|
IdentityFile = [ giteaKey ];
|
|
};
|
|
};
|
|
};
|
|
|
|
# Not editable by the agent user without `doas`; a convenience, not a boundary
|
|
environment.etc."claude-code/managed-settings.json".text = toJSON {
|
|
permissions.deny = claudeDeny;
|
|
};
|
|
|
|
systemd = {
|
|
network = {
|
|
links = {
|
|
"10-lan-untrusted" = {
|
|
matchConfig = {
|
|
Driver = "mlx5_core";
|
|
PermanentMACAddress = "52:54:00:71:22:ea";
|
|
};
|
|
linkConfig = {
|
|
Name = "lan-untrusted";
|
|
MTUBytes = toString prefixes.untrusted.mtu;
|
|
};
|
|
};
|
|
};
|
|
networks = {
|
|
"80-lan-untrusted" = mkMerge [
|
|
(networkdAssignment "lan-untrusted" assignments.untrusted)
|
|
{
|
|
# As `untrusted`'s DHCP and RAs hand out; the routers' resolvers aren't reachable
|
|
networkConfig.DNS = [
|
|
"1.1.1.1" "1.0.0.1"
|
|
"2606:4700:4700::1111" "2606:4700:4700::1001"
|
|
];
|
|
}
|
|
];
|
|
};
|
|
};
|
|
|
|
services = {
|
|
paseo = {
|
|
unitConfig.RequiresMountsFor = agentHome;
|
|
serviceConfig.EnvironmentFile = paseoPasswordFile;
|
|
# Don't interrupt running agents on deploy; restart by hand when convenient
|
|
restartIfChanged = false;
|
|
};
|
|
};
|
|
};
|
|
|
|
services.paseo = {
|
|
enable = true;
|
|
package = pkgs.paseo;
|
|
user = agentUser;
|
|
group = agentUser;
|
|
listenAddress = "127.0.0.1";
|
|
port = 6767;
|
|
|
|
relay = {
|
|
enable = true;
|
|
mode = "remote";
|
|
host = "paseo-relay.${lib.my.c.pubDomain}";
|
|
port = 443;
|
|
useTls = true;
|
|
};
|
|
|
|
# Rewritten on every start, so changes made from the app don't survive a restart
|
|
settings = {
|
|
version = 1;
|
|
# Pairing links open our copy of the web app (served by `middleman`)
|
|
app.baseUrl = "https://slop.${lib.my.c.pubDomain}";
|
|
daemon = {
|
|
# 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-bypass";
|
|
name = "Claude, bypass permissions";
|
|
provider = "claude";
|
|
modeId = "bypassPermissions";
|
|
}
|
|
{
|
|
id = "codex-full-access";
|
|
name = "Codex, full access";
|
|
provider = "codex";
|
|
modeId = "full-access";
|
|
}
|
|
];
|
|
};
|
|
# Avoids downloading the local speech model
|
|
features = {
|
|
dictation.enabled = false;
|
|
voiceMode.enabled = false;
|
|
};
|
|
agents.providers = lib.genAttrs
|
|
[ "copilot" "opencode" "pi" "omp" "antigravity" "muse" ]
|
|
(_: { enabled = false; });
|
|
log.file.level = "info";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|