| 1 | // Package valley is the canonical domain model of a valley host: what the |
| 2 | // host serves, independent of any machine that serves it. |
| 3 | // |
| 4 | // This file is deliberately not Nix. The NixOS module in this repo is one |
| 5 | // installer that consumes the model (`cue vet` + `cue export` at build |
| 6 | // time); other installers and tools read the same file. Deployment concerns |
| 7 | // — data directory, unix user, SSH keys — are machine integration and live |
| 8 | // with the installer, never here. |
| 9 | package valley |
| 10 | |
| 11 | // #Host is a complete valley host declaration: the set of projects the |
| 12 | // host serves. |
| 13 | #Host: { |
| 14 | // projects maps a project name to its declaration. Names must be |
| 15 | // filesystem- and URL-safe because they become on-disk directory |
| 16 | // names ("<name>.git") and clone paths. |
| 17 | projects: [=~"^[a-zA-Z0-9][a-zA-Z0-9._-]*$"]: #Project |
| 18 | } |
| 19 | |
| 20 | // #Project is the unit of declaration. A project *has* stores; git is the |
| 21 | // only store type today, and it is nested rather than top-level on |
| 22 | // purpose — the valley is not committed to being git-only. |
| 23 | #Project: { |
| 24 | // The project's git store. |
| 25 | git: { |
| 26 | // Whether the host serves a git repository for this project. |
| 27 | // Disabling never deletes anything: an existing repository is |
| 28 | // left untouched on disk, merely unmanaged. |
| 29 | enable: bool | *true |
| 30 | } |
| 31 | |
| 32 | // Push-mirror URLs. Every push to the primary is replicated to each |
| 33 | // URL via `git push --mirror`, which propagates deletions — the |
| 34 | // correct semantic for a mirror. Replication is best-effort: a dead |
| 35 | // mirror never rejects the primary push. Credentials are the host's |
| 36 | // concern (the installer documents how); they are not declared here. |
| 37 | mirrors: [...string] | *[] |
| 38 | } |
| 39 | |
| 40 | // The top level of this package is itself a host declaration: a config |
| 41 | // file evaluated together with this schema is validated against #Host — |
| 42 | // unknown fields and unsafe project names are rejected. |
| 43 | // |
| 44 | // cue vet -c schema/valley.cue <config>.cue |
| 45 | // cue export schema/valley.cue <config>.cue |
| 46 | projects: #Host.projects |
| 47 | |
| 48 | // A file's top level cannot be closed (embedding #Host would open it |
| 49 | // instead — embedding lifts closedness), so reject stray top-level fields |
| 50 | // explicitly: anything but `projects` — a `project:` typo, a deployment |
| 51 | // concern like `user:` — conflicts with this sentinel and fails vet with |
| 52 | // an error naming the field. |
| 53 | [!="projects"]: "INVALID: unknown top-level field; only \"projects\" is allowed" |