- Nix 60.2%
- TypeScript 34%
- Shell 5.8%
etcd defaults (100ms heartbeat / 1s election) re-elected ~266 times per 12h over the 100-1200ms WiFi mesh, dragging Patroni into ~155 leader flaps. Unbounded revision history grew the db to 1.3GB so a lagging member could never catch up by snapshot. A dead replica slot pinned WAL until two voters hit 100% disk (clan-mauke Gotcha #51). |
||
|---|---|---|
| modules | ||
| scripts | ||
| templates | ||
| tests | ||
| .gitignore | ||
| BOOTSTRAP.md | ||
| community.nix.example | ||
| flake.lock | ||
| flake.nix | ||
| GOTCHAS.md | ||
| README.md | ||
clan-community
A NixOS + clan.lol library for running a community's own infrastructure: identity, files, chat, documents, git, mail and object storage, on hardware the community owns, with no per-seat fee and no vendor holding the data.
It is a flake input, not a template. You keep your own repo — your machines,
your secrets, your values — and upgrade with nix flake update clan-community.
Nothing here knows or cares which community you are.
What it gives you
26 NixOS modules and 2 clan services, sized for a fleet of one public ingress VPS plus an odd number (≥3) of always-on local machines:
| Layer | What runs |
|---|---|
| Identity | Authentik (active-active), OIDC clients provisioned via API |
| Files | Nextcloud (active-active) on Garage S3 + HA Postgres |
| Documents | Collabora CODE (active-active, WOPI-affinity routed) |
| Chat | Mattermost (active / warm standby) |
| Code | Forgejo |
| Stalwart + SnappyMail webmail, blobs on Garage, data on HA Postgres | |
| Data | Patroni/etcd HA Postgres, Redis + Sentinel, Garage RF=3, borg cross-backup |
| Ingress | Caddy on the edge VPS, HTTP-01 certs, everything else mesh-only |
| Mesh | ZeroTier, addresses derived from clan vars — never transcribed |
| Whitelabel | one brand token set → login screens, landing page, webmail, Forgejo |
Plus the thing that took longest to earn: GOTCHAS.md — 50 entries, each a failure that cost real hours.
The design rule
Four classes of value, four mechanisms, and no leakage between them:
| Class | Where it lives | Example |
|---|---|---|
| Community identity | your community.nix |
apex domain, brand, operator |
| Derived facts | computed at eval | mesh IPv6, the /88, machine list |
| Topology / membership | clan inventory tags | who is a voter |
| Hardware / provider | your machines/<host>/ |
disko layout, facter, the droplet |
./scripts/no-community-literals.sh enforces that nothing from the first or
last column ever appears in this repo. It runs over the whole tree.
Using it
# your flake.nix
inputs.clan-community.url = "git+https://git.matou.nz/waipuna/clan-community";
machines.node01.imports =
clan-community.communityBase ++ [ ./community.nix ./machines/node01/configuration.nix ];
specialArgs.communityModules = clan-community.communityModules;
Full walk-through: BOOTSTRAP.md. Start from
community.nix.example and the role templates in
templates/.
Outputs
| Output | What it is |
|---|---|
communityBase |
the six modules every machine imports |
communityModules |
all modules individually, by name — skip what you don't run |
clanServiceModules / clan.modules |
the pg-ha and redis-ha clan services |
communityTemplates |
paths to the role-shaped configuration.nix starting points |
clan.modules is the one clan's inventory resolver reads; reference it as
module = { name = "pg-ha"; input = "clan-community"; }.
Verifying a change
./scripts/no-community-literals.sh # nothing community-specific leaked in
./scripts/drvpath-check.sh # run from YOUR repo: closures unchanged
bun tests/run.ts # live probes against your fleet
drvpath-check.sh is the honest one. It compares system.build.toplevel.drvPath
per machine against a stored baseline, so a refactor that claims to change only
where values live has to prove it. Do not re-baseline to make a diff go away.
Provenance and status
Extracted from a working four-machine fleet in the Cook Islands, which is consumer #1. The split was verified by bit-identical system closures before and after, so this library is not a hopeful generalisation — it is the same code, still running.
Known rough edges, stated rather than hidden:
tests/and the genericscripts/are copies of the reference fleet's, not a shared runtime. Two copies can drift; making a consumer run the library's harness directly needstests/lib/fleet.tsto take the consumer's flake directory as a parameter. Not done yet.templates/frontend/configuration.nixreferences../../scripts/authentik-{provision,brand}.sh— copy those two into your ownscripts/when you copy the template.clan-coreis pinned here, and the library is only tested against that rev.inputs.clan-core.follows = "clan-community/clan-core"is the recommended wiring; clan's inventory/service API is still stabilising.community.mesh.ifaceand per-machine hardware remain manual knobs, for reasons argued at their declaration sites.
Licence
Not yet declared. Ask before redistributing.