Inside each machine

Five machines, the same three ingredients: roles from the inventory, shared modules, and a few lines of their own. One bench per machine, with the code that puts each part there.

Code is quoted from the repository and shortened. Addresses, keys, account identifiers and domain names are replaced by <placeholders>; no secret value exists in the repository to begin with.

How a machine is assembled

Every machine is the sum of three declarations: the roles the inventory gives it, the shared modules its own file imports, and a few lines that belong to it alone.

A role in the inventory

An instance names a module and says which machines hold which role. Nothing else is needed to put a service on a machine; removing the line removes the service at the next update.

# clan.nix
inventory.instances.forgejo = {
  module = { name = "@rasyidanaf/forgejo"; input = "self"; };
  roles.server.machines."greencloud-vps".settings = {
    domain = "git.<domain>";
    httpPort = 3000;
    useCloudflare = true;
  };
};

A secret that is never typed into a host

Secrets are declared as generators. Clan prompts for or generates the value once, stores it SOPS-encrypted under vars/, and hands the service a file path at runtime. The repository only ever contains the path expression.

# a generator: what to ask for, what to write
clan.core.vars.generators.forgejo-actions-runner = {
  prompts.registration-token.type = "hidden";
  files."registration.env".secret = true;
  script = ''
    printf 'TOKEN=%s\n' "$(cat "$prompts/registration-token")" > "$out/registration.env"
  '';
};

# a consumer: a path, never a value
tokenFile = config.clan.core.vars.generators.forgejo-actions-runner.files."registration.env".path;

Build, then deploy

A build proves the whole closure evaluates and compiles before any machine is touched. An update copies that closure over the tailnet and switches to it; the previous generation stays on disk as the rollback.

clan machines build hermes-vm      # evaluate and build, change nothing
clan machines update hermes-vm     # copy the closure, activate it
scripts/verify full                # every offline check plus all five builds

greencloud-vps · the public edge

The only machine with public ingress. It holds eleven inventory cards, more than any other except dalang-dev, and it is the build host for three of the other four.

own VPS · no neighboursgreencloud-vpsany interfacetailscale0
The part under the pointerTall card: module from this repository · short card: clan-coreOne tab and lamp per role the machine holds

Inventory cards · roles held here

Shared modules imported

Firewall openings

Eleven cards and five modules. The four-tab card is buzz, which gives this machine the gateway, storage, observer and media-backup roles at once. Only four posts face the internet: SSH, HTTP, HTTPS and the ZeroTier port. The deploy path on 2222 is a tailnet post.

Ingress: Caddy with DNS-01 certificates

Public names terminate at Caddy. Certificates come from a DNS challenge, so the API token is read from a vars file and no port has to be opened for validation. Upstreams are addressed over the tailnet.

services.caddy.virtualHosts."s3.<domain>".extraConfig = ''
  tls {
    dns cloudflare {file.${config.clan.core.vars.generators.forgejo-cloudflare.files.api-token.path}}
  }
  reverse_proxy <tailnet address>:3900
'';

Observability: the one server, five agents

This machine runs the stores and the dashboards; every machine, this one included, runs a node exporter and a Vector agent. Adding a machine to monitoring is one more name in a list.

services.observability = {
  victoriametrics.enable = true;
  victorialogs.enable = true;
  grafana = { enable = true; domain = "grafana.<domain>"; };
  uptimeKuma = { enable = true; domain = "uptime.<domain>"; };
  vmagent = {
    enable = true;
    scrapeTargets = [{
      job = "node";
      targets = [ "localhost:9100" "dalang-dev:9100" "greencloud-us:9100" "hermes-vm:9100" "lab-vm:9100" ];
    }];
  };
};

Firewall and exit node

The firewall is the whole policy: three TCP ports for the world, one more for the tailnet. NAT and forwarding exist because the machine is also a Tailscale exit node.

networking.firewall = {
  allowedTCPPorts = [ 22 80 443 ];
  allowedUDPPorts = [ 9993 ];                              # ZeroTier
  interfaces.tailscale0.allowedTCPPorts = [ 2222 ];       # Clan deploy path
};
services.tailscale.extraSetFlags = [ "--advertise-exit-node" "--ssh" ];

greencloud-us · the third replica

The smallest machine: the five cards every machine has, plus Garage. It exists so that object storage keeps a replica outside the other two failure domains.

own VPS · no neighboursgreencloud-usany interfacetailscale0
The part under the pointerTall card: module from this repository · short card: clan-coreOne tab and lamp per role the machine holds

Inventory cards · roles held here

Shared modules imported

Firewall openings

Five cards, four of them the common set every machine carries, and four modules. Compare the empty slots with greencloud-vps: the same cage, the same slot numbers, fewer pins in its column.

Garage: one inventory line, three nodes

The inventory places the same role on three machines. The shared module holds everything the nodes must agree on, so a machine only supplies its own tailnet address for RPC.

# clan.nix
inventory.instances.garage.roles.default.machines = {
  "greencloud-vps" = { };
  "greencloud-us" = { };
  "dalang-dev" = { };
};

# machines/greencloud-us/configuration.nix
imports = [ ../../modules/garage-cluster.nix ];
services.garageCluster.tailnetAddress = "<tailnet address>";

dalang-dev · private workloads

A VM that nothing public reaches. It holds eleven cards: the finance agent, the Buzz relay and its database, a Garage replica, and the receiving end of the off-host backups.

ubuntu-baremetaldalang-devany interfacetailscale0
The part under the pointerTall card: module from this repository · short card: clan-coreOne tab and lamp per role the machine holds

Inventory cards · roles held here

Shared modules imported

Firewall openings

Eleven cards and four modules. The three-tab card is buzz again, this time as relay, database backup and media repository. Two posts only: no TCP port is open outside the tailnet.

Least privilege, declared

The same service gives two machines different rights. Agents on hermes-vm may publish; workloads here may store and fetch but can never make a link public, and that rule lives in the inventory where a review will see it.

artifact-sharing.roles = {
  server.machines."greencloud-vps".settings.publicHost = "share.<domain>";
  client.machines."hermes-vm".settings.user = "hermes";
  client.machines."dalang-dev".settings = {
    user = "agent";
    scopes = [ "upload" "read_private" "delete" ];     # no public scope
  };
};

Backups that cross hardware

Two borgbackup instances point in opposite directions, so each side's data lands on the other side's disk. The schedule and the exclusions are part of the declaration.

buzz-postgresql-backup = {
  module = { name = "borgbackup"; input = "clan-core"; };
  roles.server.machines."greencloud-vps".settings.directory = "/var/lib/borgbackup/buzz-postgresql";
  roles.client.machines."dalang-dev".settings = {
    startAt = "*-*-* 00/6:00:00";
    exclude = [ "/var/lib/postgresql" "/var/lib/redis-buzz" ];   # logical dumps only
  };
};

hermes-vm · the development machine

The agentic development VM, and the machine this page was built on. It has the fewest public surfaces and the most modules: twelve, against four or five everywhere else.

ubuntu-baremetalhermes-vmany interfacetailscale0
The part under the pointerTall card: module from this repository · short card: clan-coreOne tab and lamp per role the machine holds

Inventory cards · roles held here

Shared modules imported

Firewall openings

Eight cards and twelve modules. The module rail is where this machine differs: agent git identity, the control plane, the toolbox, shared AI secrets, two caches, a browser server and remote terminals are all clip-on blocks, each one an imports line.

What the twelve imports add

The machine file is mostly a list. Each module carries its own options, units and secrets, so the file reads as an inventory of capabilities and stays short.

# machines/hermes-vm/configuration.nix
imports = [
  ../../modules/agent-git.nix            # git identity and forge access
  ../../modules/clan-control-plane.nix   # clan-operator: the deploy account
  ../../modules/security-baseline.nix
  ../../modules/hermes-toolbox.nix       # CLI tools on the agent's PATH
  ../../modules/ai-secrets.nix           # provider keys through SecretSpec
  ../../modules/observability
  ../../modules/dev/containers.nix       # Podman
  ../../modules/nixvim.nix
  ../../modules/camofox-server.nix       # browser server for agent tools
  ../../modules/tern-remote.nix          # remote terminals over the tailnet
  ../../modules/kache.nix                # compiler cache
  ../../modules/nix-cache.nix            # shared binary cache, pull only here
];

Hermes Agent: one service, four isolated profiles

The hermes-agent card expands into profiles. Each profile is a separate environment with its own configuration, skills, sessions, memory and state database, and each gateway profile gets its own systemd unit.

defaultcodingresearchbuzz
Lamp: this profile has its own Telegram botLarge unit: the profile · small unit behind: its delegatePosts: a dashboard port and its HTTPS front

Profiles

Four units on one bus. Every profile hands hard sub-tasks to a smaller delegate unit running gpt-5.6-luna at maximum effort. coding and research carry dashboard posts; default does not. buzz has a blanking plate where the gateway spindle would be, because its only long-running process belongs to the Buzz agent role, and an empty seat where the Telegram lamp would be.

# clan.nix → hermes-agent.roles.server.machines."hermes-vm".settings
defaultModel = "deepseek-v4.1-flash";
defaultProvider = "opencode-go";
fallbackProviders = [{ provider = "crofai"; model = "deepseek-v4-flash"; }];

profiles.coding = {
  defaultModel = "gpt-5.6-sol";
  defaultProvider = "openai-codex";
  reasoningEffort = "high";
  enableLsp = true;
  telegramBotTokenVar = "hermes-telegram-coding";   # the name of a var, not a token
  soul = ./services/hermes-agent/profiles/coding/SOUL.md;
  delegation = { model = "gpt-5.6-luna"; reasoningEffort = "max"; maxIterations = 75; };
  dashboard = { port = 9120; httpsPort = 8443; };
};

profiles.buzz = {
  enableGateway = false;       # ACP owns this profile's only process
  bundledSkillsInclude = [ "software-development/*" ];
};

OpenCode 2: a coding server the tailnet can reach

One server, bound to the tailnet interface only, sharing the agent's execution identity. The repositories it should offer are declared; the service clones what is missing and never pulls or resets a checkout.

opencode2.roles.server.machines."hermes-vm".settings = {
  port = 4097;
  user = "hermes";
  projectRoot = "/var/lib/hermes/projects";
  tailscaleOnly = true;
  useSharedAiSecrets = true;
  managedSettings = { update = "disable"; snapshots = true; };
  repositories.personal-clan-nix = {
    url = "ssh://git@git.<domain>/<owner>/personal-clan-nix.git";
    branch = "main";
  };
};

Shared AI secrets

Provider keys are Clan vars. This module exposes a chosen set to the interactive tools through SecretSpec, so enabling a provider is a boolean and no key is ever written into a dotfile by hand.

services.aiSecrets = {
  enable = true;
  providers = {
    openrouter.enable = true;
    zai.enable = true;
    xai.enable = true;
    openCodeGo.enable = true;
    crofai.enable = true;
    exa.enable = true;
    parallel.enable = true;
  };
};

The control plane: deploying the cluster from inside it

A separate clan-operator account holds its own deploy and SOPS identities and a read-only checkout. Target host keys are pinned from the public halves already in vars/, so a deploy cannot be redirected to an impostor. The deploy key itself is accepted by the other machines only from this machine's tailnet address, with forwarding and PTYs refused.

services.clanControlPlane = {
  enable = true;
  forgejoApiTokenFile = config.clan.core.vars.generators.forgejo-agent.files.api-token.path;
  targetHosts.greencloud-vps = {
    aliases = [ "greencloud-vps" "<tailnet address>" ];
    port = 2222;
    publicKey = builtins.readFile ../../vars/per-machine/greencloud-vps/openssh/ssh.id_ed25519.pub/value;
  };
};

# clan.nix → sshd.roles.server.settings.authorizedKeys
"clan-control-plane" = ''restrict,from="<hermes-vm tailnet address>,127.0.0.1" ssh-ed25519 <public key>'';

Containers without a root daemon

Agents get Podman, rootless, with their own sub-UID range. The rootful socket and service are switched off outright, and the docker-compatible socket with them.

users.users.hermes.subUidRanges = [{ startUid = 100000; count = 65536; }];
virtualisation.podman.dockerSocket.enable = lib.mkForce false;
systemd.sockets.podman.enable = lib.mkForce false;
systemd.services.podman.enable = lib.mkForce false;
systemd.user.sockets.podman.wantedBy = lib.mkForce [ "sockets.target" ];

Two caches, two jobs

kache caches compiler invocations for ordinary builds; the Nix binary cache does the same for whole derivations. Here the binary cache is pull-only, since this machine builds system closures that are not worth storing.

services.kacheBuildCache = {
  enable = true;
  user = "hermes";
  localMaxSize = "30GB";
  remote = { enable = true; bucket = "kache-build-cache"; cloudflareAccountId = "<account id>"; };
};
services.nixBinaryCache = { enable = true; bucket = "nix-cache"; cloudflareAccountId = "<account id>"; };

lab-vm · staging and CI

Where a service is tried before it is promoted, and where the forge's CI jobs run. Its one distinctive card, pikpak-s3, is an experiment that has not left staging.

ubuntu-baremetallab-vmany interfacetailscale0
The part under the pointerTall card: module from this repository · short card: clan-coreOne tab and lamp per role the machine holds

Inventory cards · roles held here

Shared modules imported

Firewall openings

Five cards and five modules. The lone tall card is pikpak-s3. Promotion is a move of one pin: public services go to greencloud-vps, private workloads to dalang-dev, agent workloads to hermes-vm.

A CI runner as configuration

The runner registers with the forge using a token from vars and runs jobs on the host with a fixed set of packages. Its systemd unit is confined in the same file.

services.gitea-actions-runner = {
  package = pkgs.forgejo-runner;
  instances.lab = {
    enable = true;
    url = "https://git.<domain>";
    tokenFile = config.clan.core.vars.generators.forgejo-actions-runner.files."registration.env".path;
    labels = [ "lab-nix:host" ];
    settings.runner = { capacity = 1; timeout = "3h"; };
  };
};
systemd.services.gitea-runner-lab.serviceConfig = {
  NoNewPrivileges = true;
  PrivateTmp = true;
  ProtectHome = "read-only";
  ProtectSystem = "strict";
};

Operational lessons, kept as code

The three VMs share one disk. After CI bursts starved a guest, the fix went into the configuration with its reason beside it, where the next reader will find it.

nix.gc = { automatic = true; dates = "daily"; options = "--delete-older-than 7d"; };
nix.settings = {
  max-jobs = 1;                          # one shared disk: serialise builds
  min-free = 4 * 1024 * 1024 * 1024;     # collect before a low-space build
};