Skip to content

The reference fleet

templates/fleet is a complete running specification of yen. It models every capability of Den, den-hoag and clan, and the advanced cases of several real fleets. Each pattern has a check. It is big on purpose: read these docs first, then use the fleet to look up how a pattern looks at scale.

This index is read from the fleet’s files: each row is a module and its first comment line.

Terminal window
git clone https://github.com/vic/yen && cd yen/templates/fleet
nix eval --impure --file tests.nix failed # [ ]: a check for each pattern
ModuleWhat it shows
adda/services.nixadda: service aspects give their domains; the caddy host reads them as virtual hosts. The fleet also exports flake templates.
ModuleWhat it shows
agent/invariants.nixFleet invariants: Datalog rules over the fleet’s facts (kind:K:ID, has:ASPECT:ID, edge:SINK:FROM:TO,
agent/mcp.nixThe MCP server as a flake app: nix run .#yen-mcp from the fleet directory serves the fleet in $PWD on stdio.
agent/queries.nixStored queries, labels and valid time for agents.
agent/rdf.nixThe fleet as a knowledge pack: sorted N-Triples and their sha256 (yen.lib.rdf). The same fleet gives the same hash
agent/synthesis.nixSynthesis an agent can call (stored queries, so ask and the MCP server reach them). Each answer is checked
ModuleWhat it shows
clan/inventory.nixclan’s inventory in yen: a service instance is data. Each machine spawns one member scope per (instance, role)
clan/services.nixclan services written in yen. A service is data (roles, typed interface, constraints, nested instances) plus
clan/vars.nixclan vars, the configuration half: services declare generators; generation itself is a tool, not yen.
ModuleWhat it shows
den/batteries.nixDen batteries are ordinary aspects here: hostname is in features/base.nix, define-user in user-account, primary-user in sini/users.nix.
den/custom-classes.nixDen custom classes and chained forwards: a user git sink forwards into homeManager, which forwards into the machine’s os.
den/ids.nixDen: deterministic ids from sorted names (no state). Each host gets its own ssh port.
den/os-config.nixDen/home-manager osConfig: each host gives its realized config to an osConfig sink. A homeManager module
den/patterns.nixDen CI usage patterns not shown elsewhere in the fleet (vic/den-patterns.md #22 #23 #26 #48 #63 #67 #77 #103 #115 #116).
den/presence-structure.nixDen #525 (a policy gated on hasAspect that creates structure): a backup job scope exists under every host where the
den/standalone-home-on-host.nixden#739: Den cannot pipe host data (a quirk) to a standalone home tux@igloo, only to a home-manager module home.
ModuleWhat it shows
docs/readme.nixREADME.md: the guide (_guide.md) plus live tables and diagrams computed from the fleet’s own queries.
ModuleWhat it shows
features/base.nixbase: every machine. Its records key lives in dns.nix: one aspect, two files.
features/deploy.nixdeploy is one per host; tags are a set; vars are generated-value plans, never values.
features/dns.nixbase’s second file: every machine’s A record. dns reads the pool at the edge environment.
features/home-manager.nixOne aspect, two platform keys: each key lands where its sink is.
features/impermanence.nixA set collector with a per-host filter (sini cortex-cuda unpersist).
features/kernel.nixA cascade: host, then its environment, then the environment’s base. Data queries, no merge.
features/monitoring.nixTyped elements (of): each replica gives one scrape job; lb reads the pool.
features/motd.nixsubstitute: motd-short replaces motd on web-2 through not.
features/overlays.nixA root emission: the overlay goes to the fleet’s overlays pool; every machine reads it. A wrapped final: prev:.
features/packages.nixPer-system outputs, a VM check, and a check on a realized config (#60).
features/secrets.nixPer-aspect flake inputs (flake-file) and module imports. vm-host: a host that has a guest.
features/sync.nixparent: alice’s syncthing devices are her other parents. holds inside content: the tray on desktops.
features/web.nixThe diamond: nginx is reached directly and through status (web-1, stage). It lands once per scope.
ModuleWhat it shows
flake/ci.nixCI from the fleet itself: every buildable config gives one job. ci.json is a generated file, so its check fails when the infra changes and nobody regenerated it.
flake/files.nixRepo files (README.md, ci.json) generated by github:sini/files. Each file gets a check: the committed file must match.
flake/flake-file.nixflake.nix is generated: each aspect declares the inputs it uses on the flake-file sink (github:vic/flake-file).
flake/infra.nixChecks derived from the infra: aspects state facts from fleet data; checks.x86_64-linux.infra-<host> compares each fact with the realized NixOS config.
ModuleWhat it shows
hoag/ci.nixden-hoag CI capabilities, each as plain data and plain Nix: merge strategies with provenance, setting refs,
hoag/claims.nixden-hoag productions: claim / provide with the reverse read (who claims me). Apps claim databases; the database host
hoag/class-share.nixden-hoag class-share (A18) as a capability: the config every member of a class shares is computed ONCE (the core),
hoag/collectors.nixden-hoag collectors: an aggregate is an entity. A hive has its own content (its meta sink) and selects its members
hoag/relations.nixden-hoag relations + query calculus: a relation is a ref field; queries are yen.lib.graphs over it.
hoag/settings.nixden-hoag A8/A14/A10: aspect settings in layers with authority, and an aspect that projects settings onto other aspects.
ModuleWhat it shows
hosts/alice-laptop.nixA standalone home: alice on the edge channel, no machine above.
hosts/apps.nixFour app hosts to compare shared pkgs: app-1..3 reuse one pkgs (app-1 leads), app-4 builds its own.
hosts/ci.nixci is a guest on stage, built with the stable channel while stage uses edge.
hosts/inventory.nixweb-1 and web-2 come from JSON: their names become refs.
hosts/lb.nix
hosts/pixel.nix
hosts/stage.nix
hosts/studio.nix
ModuleWhat it shows
platforms/darwin.nixmacOS: the darwin sink; os fans out to darwin.
platforms/droid.nixPhones: nix-on-droid. Only phone users live here; their homes go to the droid config.
platforms/home-manager.nixUsers and standalone homes. A user’s homeManager goes to its machine’s os, or up to a phone or home.
platforms/microvm.nixGuests: a microvm on a host. Its nixos forwards to the host (a key with the sink’s own name goes up).
platforms/nixos.nixNixOS hosts: the nixos sink builds the system; os fans out to nixos (#76).
platforms/variants.nixDen specialisations: a variant scope under a host; its nixos forwards into the host’s specialisation.
ModuleWhat it shows
query/datalog.nixA serving policy in Datalog with negation. Nix grounds the rules from fleet data (one per host); the well-founded
query/krn.nixConfiguration synthesis with krn (µKanren with =/= and finite domains). The fleet states constraints; krn finds
ModuleWhat it shows
sini/clusters.nixClusters under an environment. Discovery (den collect): k3s nodes reduce at the environment; the reader filters.
sini/domains.nixRecursive kinds: domains under domains. parent is a scope key, so the field is under.
sini/flake-level.nixFlake level: sink -> sink chains, and elements that read one out path and write another.
sini/joins.nixsini joins and data-shaped aspects: two pools joined by host, a guest’s intent read by its parent,
sini/mesh.nixsini mesh family (vault, thunderbolt, ollama, nix-builders): every host in an environment gives one record;
sini/network.nixConditional environment receivers fed by hosts (terranix, unifi port-forwards).
sini/roles.nixTags: a set per host; nixos.colmena adds the environment and the active role aspects. A host profile does not reach the host’s guests (#67).
sini/secrets.nixage-secrets: one sink name on three kinds. A body that reads config is a module element. Unfree names collapse in a set.
sini/services.nixsini services: SSO identities per environment, a provider allow-list joined from fleet pools,
sini/settings.nixPer-feature settings: two files declare types at two paths of one field. Cascade with delegation.
sini/syncthing.nixBroadcast to the same user elsewhere, and to a hub, with a transform (syncthing-peers, replicateHome).
sini/users.nixhomeLinux: a user sink that only users on linux machines have. Primary user: a user element that goes up to the host.
sini/xmsg.nixTrust graph: the filter lives with the reader.
ModuleWhat it shows
swarsel/distributed.nixswarsel (after oddlama): distributed config. One machine writes NixOS config into another (old nodes.<name>),
swarsel/exports.nixswarsel exports: aspects used outside yen. An export scope never builds a machine;
swarsel/variants.nixswarsel: one machine, two builds. lb-minimal is a host scope under lb: same data, its own nixosConfiguration.
ModuleWhat it shows
topology/access.nixGroups are data: nothing spawns them, so they have no scopes. Groups nest through members.
topology/channel.nixChannels: which nixpkgs and home-manager a machine builds with.
topology/environments.nixEnvironments own hosts, macs and phones (parent-side spawns) and two pools.
topology/fleet.nixThe root kind: nothing spawns it. Its sinks are the flake outputs and the fleet-wide pools.
topology/machines.nixmachine is data only (nothing spawns it): host, guest and mac copy its fields.
topology/replicas.nixA relation kind: a replica is a (db, region) pair; the fleet spawns only matching pairs.
topology/systems.nixOne system scope per platform: per-system flake outputs.
ModuleWhat it shows
users/alice.nix
users/bob.nix
users/dana.nix
ModuleWhat it shows
vix/editors.nixvix: a child kind declared in another file. Each system gets editor profiles; features gate aspects;
vix/secrets.nixvix: secrets are a data kind (no scopes). Features give the secrets they need on the user’s secrets sink.
Contribute Community Sponsor