diff --git a/hosts/wynne/services/apps/default.nix b/hosts/wynne/services/apps/default.nix index 2874841..c8f4324 100644 --- a/hosts/wynne/services/apps/default.nix +++ b/hosts/wynne/services/apps/default.nix @@ -2,6 +2,7 @@ _: { imports = [ ./dendrite ./acomputer.lol.nix + ./forgejo.nix ./ntfy.nix ./postgresql.nix ../../../shared/prometheus-exporters.nix diff --git a/hosts/wynne/services/apps/forgejo.nix b/hosts/wynne/services/apps/forgejo.nix new file mode 100644 index 0000000..e916fd2 --- /dev/null +++ b/hosts/wynne/services/apps/forgejo.nix @@ -0,0 +1,59 @@ +{ config, lib, ... }: +let + inherit (import ../../../shared/caddy-helpers.nix) logFormat; + domainName = "forge.acomputer.lol"; + cfg = config.services.forgejo; +in +{ + services = { + caddy.virtualHosts."${domainName}" = { + logFormat = logFormat domainName; + extraConfig = '' + reverse_proxy ${cfg.settings.server.HTTP_ADDR}:${toString cfg.settings.server.HTTP_PORT} + ''; + }; + frp.settings.proxies = [ + { + name = "http.${domainName}"; + type = "http"; + customDomains = [ "${domainName}" ]; + localPort = 80; + transport.useCompression = true; + } + { + name = "https.${domainName}"; + type = "https"; + customDomains = [ "${domainName}" ]; + localPort = 443; + transport.useCompression = true; + } + ]; + forgejo = { + enable = true; + stateDir = "/mnt/data/Forgejo"; + settings = { + database = { + DB_TYPE = lib.mkForce "postgres"; + HOST = "127.0.0.1:5432"; + USER = cfg.database.user; + NAME = cfg.database.name; + }; + server = { + ROOT_URL = "https://${domainName}"; + PROTOCOL = "http"; + SSH_PORT = 42069; + HTTP_ADDR = "127.0.0.1"; + HTTP_PORT = 3000; + DOMAIN = domainName; + }; + session = { + COOKIE_SECURE = true; + }; + service = { + DISABLE_REGISTRATION = true; + }; + }; + database.createDatabase = true; + }; + }; +} diff --git a/hosts/wynne/services/apps/postgresql.nix b/hosts/wynne/services/apps/postgresql.nix index 83816ff..b410c5d 100644 --- a/hosts/wynne/services/apps/postgresql.nix +++ b/hosts/wynne/services/apps/postgresql.nix @@ -16,12 +16,16 @@ host all all 10.10.10.0/24 trust host all all fd7c:585c:c4ae::0/64 trust ''; - ensureDatabases = [ "dendrite" ]; + ensureDatabases = [ "dendrite" "forgejo" ]; ensureUsers = [ { name = "dendrite"; ensureDBOwnership = true; } + { + name = "forgejo"; + ensureDBOwnership = true; + } ]; }; };