Forgejo module with fresh-install and plain-http modes, exported as nixosModules.forgejo #136
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/archetypes#136
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A deployment built from the public templates can run a Forgejo of its own on the hypervisor once this repo exports a Forgejo NixOS module that boots fresh, with no restored dump, and serves plain http on a private network. Part of allod/strategy#65 (slice 1 of four); the
forgemachine in the templates, the hypervisor bootstrap and the dev VM's flip are separate issues on their owning repos.Primary goals:
nixosModules.forgejo, ported from a deployment's production module, withmode = "restore" | "fresh"andtls = true | false, both defaulting to the production shape so a consumer that sets neither gets today's behaviour unchanged.forgejo-secretsunit generate the four application secrets, generates the clone daemon's host keys, and writes the state marker that gates every Forgejo unit; restore mode keeps the marker, the secret files andrestore-forgejoexactly as they are.ROOT_URL, the Caddy site address,COOKIE_SECURE, and port 443 leaving the firewall set; the check evaluates both configurations side by side and asserts the difference is that list and nothing more.forgenode in fresh plain-http mode and aclientnode, where the client reaches Forgejo through the advertised URL, an admin created on the forge mints a token for the agent account into a 0600 file on the client, the client creates a repository and registers its key through the API, clones it over the clone port and pushes, the administrative port accepts the operator key and refuses a second valid key, the generated secrets have the owner and mode nixpkgs gives them, and the token appears nowhere in either machine's journal or the test driver's log.Current state and specifics
The deployment module this ports lives in a private repo and assumes a public domain with ACME and a restored dump:
services.forgejo.secretsis forced to four restored files,forgejo-secrets.serviceis replaced by a check that the files exist, andforgejo.serviceand the clone daemonforgejo-sshd.servicecarryConditionPathExistson a marker the operator creates afterrestore-forgejo. Everything else in it — the clone-only sshd on its own port with per-key forced commands into a setuid dispatcher, administrative sshd on another port, Caddy in front of Forgejo's loopback listener, fail2ban, the dump unit, the port-collision and listen-address assertions — is deployment-neutral and ports as is.Fresh mode adds
forgejo-fresh-init.service, ordered beforeforgejo-secrets,forgejoandforgejo-sshd, conditioned on the marker's absence: it creates the state directory, generates ed25519, ecdsa and rsa host keys for the clone daemon under the state directory, and installs the marker root-owned at mode 0600. nixpkgs 26.05 ships Forgejo 16.0.5, so fresh mode needs no package pin. The secret files nixpkgs generates land under the custom directory owned by the Forgejo user at the mode itsUMaskgives them; the witness measures and asserts that, rather than the restore shape's root-owned files.The module lives at
modules/forgejo/besidemodules/public-host.nixand is exported asnixosModules.forgejo; it does not importpublicHost, because a forge on a private network has no ACME and the stateful posture (state gate, restore tooling, secrets that must not be regenerated) is whatpublicHostdeliberately leaves out. The check ischecks/forgejo.nix, one entry inchecks/default.nix, run byallod checklike the rest; it is arunNixOSTestwith eval-time assertions ahead of it, followingchecks/static-site.nix.Custody rule, binding on the witness and on every later slice: no password or token is ever a command-line argument, to
ssh,curl,forge,jqorforgejo. The admin account takes Forgejo's random password flagged must-change; the agent account takes a random password nobody keeps; the token is minted withforgejo admin user generate-access-token --rawand travels to the client as a file the test driver copies, where curl reads the authorization header from a config on stdin. The witness proves it by grepping both journals for the token's value and the driver log for anything token-shaped, and finding nothing.Scope
In:
modules/forgejo/, its export,checks/forgejo.nix, the index entry and the README's Exports line. Out: theforgemachine ininventory,profilesandsecrets;forge-bootstrapon the hypervisor; the dev VM's flip to the local forge; TLS on the private network; promotion of a forge VM to a VPS. Each is its own issue under allod/strategy#65.Landed on master as
408e1e5: the module, its export and the two-node check. The relay rewrote the commit hash from the worktree commit, so the branch was never pushed.