From 95b58de737585be1a56e147dcda8c817f8c47384 Mon Sep 17 00:00:00 2001 From: emilylange Date: Tue, 16 Jul 2024 20:09:15 +0200 Subject: [PATCH] forgejo: use redis as cache and session provider --- services/forgejo/default.nix | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/services/forgejo/default.nix b/services/forgejo/default.nix index b4de166..dedda99 100644 --- a/services/forgejo/default.nix +++ b/services/forgejo/default.nix @@ -45,7 +45,8 @@ in }; session = { - PROVIDER = "db"; + PROVIDER = "redis"; + PROVIDER_CONFIG = "network=unix,addr=${config.services.redis.servers.forgejo.unixSocket},db=0"; COOKIE_NAME = "session"; }; @@ -60,7 +61,12 @@ in }; # TODO: transactional mails - # TODO: redis cache instead of default in-memory + + cache = { + ADAPTER = "redis"; + HOST = "network=unix,addr=${config.services.redis.servers.forgejo.unixSocket},db=1"; + ITEM_TTL = "72h"; # increased from default 16h + }; ui = { SHOW_USER_EMAIL = false; @@ -106,8 +112,13 @@ in # start Forgejo *after* sshd.service, so in case Forgejo tries to wildcard bind :22 due to # a bug or whatever, we don't lose OpenSSH in a race. - wants = [ "sshd.service" ]; - requires = [ "sshd.service" ]; + wants = [ "sshd.service" "redis-forgejo.service" ]; + requires = [ "sshd.service" "redis-forgejo.service" ]; + }; + + services.redis.servers.forgejo = { + enable = true; + user = "forgejo"; }; services.nginx = {