Files
rose-ash/lib/gitea/serve.sx
giles 9c009b07db sx-gitea deploy: live serving for sx.sx-web.org
lib/gitea/serve.sx: durable live forge on the kernel persist store
(SX_PERSIST_DIR) with idempotent seeding (instance id, admin user +
rotating token, welcome repo), blocking in the native http-listen loop
via host/native-handler — the same wiring that serves blog.rose-ash.com.

lib/gitea/serve.sh: full-stack launcher (every substrate the eight
phases compose, in dependency order, + dream/session for the cookie
bridge) — container entrypoint and local launcher in one.

docker-compose.dev-sx-gitea.yml: sx_docs image, bind-mounted worktree +
binary, /root/sx-gitea-persist for durable state, externalnet so Caddy
can proxy sx.sx-web.org. Serving JIT off until validated for this path.

Smoke-tested locally: pages, authed API, markdown-rendered issues,
pkt-line ref advertisement, 401 gating, and full state survival across
a restart against the same persist dir.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 15:20:14 +00:00

62 lines
2.3 KiB
Plaintext

; lib/gitea/serve.sx — live-serving boot for sx-gitea.
;
; The live forge runs on the kernel's DURABLE persist backend (perform ->
; sx_persist_store under $SX_PERSIST_DIR), so repos, issues, PRs, tokens
; and activity all survive restarts. Seeding is idempotent: the instance
; id and admin token are (re)written each boot (rotating the env rotates
; the token), the admin user and welcome repo create-only.
;
; gitea/serve! blocks inside the kernel http-listen loop, bridging the
; dream app through host/native-handler — the exact wiring that serves
; blog.rose-ash.com.
;
; Requires: the full gitea stack (see lib/gitea/serve.sh) plus
; lib/host/server.sx (host/native-handler).
(define gitea/live-forge-cache false)
(define
gitea/live-forge
(fn
()
(begin
(if
gitea/live-forge-cache
nil
(set! gitea/live-forge-cache (gitea/forge (persist/durable-backend))))
gitea/live-forge-cache)))
(define
gitea/welcome-md
"# sx-gitea\n\nA federated git forge written entirely in SX — repos, issues, pull\nrequests, activity, search and ForgeFed federation composed from the\nx-on-sx subsystems (sx-git, acl, content, relations, flow, feed,\nevents, search) on the OCaml kernel. Zero third-party dependencies.\n\nBrowse: `/<owner>/<repo>`, `/issues`, `/pulls`, `/activity`,\n`/<owner>/<repo>/search?q=...`\n\nClone over the native smart-HTTP wire: `GET /<owner>/<repo>/info/refs`.\n")
(define
gitea/seed!
(fn
(forge instance admin token)
(begin
(gitea/instance! forge instance)
(gitea/user-create! forge admin)
(gitea/token-create! forge admin token)
(let
((res (gitea/repo-create! forge admin "welcome" {:description "Welcome to sx-gitea — a federated git forge in plain SX"})))
(if
(get res :conflict)
nil
(let
((grepo (gitea/repo-git forge admin "welcome")))
(begin
(git/add! grepo "README.md" gitea/welcome-md)
(git/commit! grepo {:message "welcome" :time 0 :author admin})
nil))))
forge)))
; blocks: the kernel http-listen loop serves the forge
(define
gitea/serve!
(fn
(port instance admin token)
(let
((forge (gitea/seed! (gitea/live-forge) instance admin token)))
(http-listen port (host/native-handler (gitea/app forge))))))