bucur/modules/services/forgejo.nix

53 lines
1.8 KiB
Nix
Raw Permalink Normal View History

2026-07-23 11:39:18 +02:00
{ ... }:
let
domain = "code.randogoth.com";
port = 3000; # localhost-only HTTP backend, proxied by Caddy
in
{
services.forgejo = {
enable = true;
database.type = "sqlite3"; # default; explicit for clarity
lfs.enable = true; # git-LFS support
settings = {
server = {
DOMAIN = domain;
ROOT_URL = "https://${domain}/";
HTTP_ADDR = "127.0.0.1";
HTTP_PORT = port;
2026-07-23 12:42:12 +02:00
# Git-over-SSH via Forgejo's built-in server on a dedicated port.
START_SSH_SERVER = true;
SSH_PORT = 2222; # advertised in clone URLs
SSH_LISTEN_PORT = 2222; # built-in server listen port
2026-07-23 12:50:27 +02:00
SSH_USER = "git"; # login user in clone URLs (default is the run user)
2026-07-23 12:53:09 +02:00
BUILTIN_SSH_SERVER_USER = "git"; # login user the built-in server accepts
2026-07-23 12:42:12 +02:00
# SSH_DOMAIN defaults to DOMAIN (code.randogoth.com)
2026-07-23 11:39:18 +02:00
};
service = {
DISABLE_REGISTRATION = true; # admin creates accounts
};
# Quiet, sane defaults for a private instance.
"repository".DEFAULT_PRIVATE = "private";
session.COOKIE_SECURE = true;
log.LEVEL = "Info";
};
};
# System-wide SSH client config so root (the nix daemon) can fetch this
# Forgejo's own flake inputs. Reuses the existing /etc/ssh/codeberg_id_ed25519
# deploy key (its public half is registered on the randogoth Forgejo account) —
# the same key all other flake inputs migrated off Codeberg now use too.
2026-07-23 12:42:12 +02:00
programs.ssh.extraConfig = ''
Host ${domain}
Port 2222
IdentityFile /etc/ssh/codeberg_id_ed25519
StrictHostKeyChecking accept-new
'';
2026-07-23 11:39:18 +02:00
# Caddy reverse proxy fragment — picked up via the glob import in caddy.nix.
environment.etc."caddy/Caddyfile.d/forgejo.caddyfile".text = ''
${domain} {
reverse_proxy localhost:${toString port}
}
'';
}