infra/config/services/gitea.nix

98 lines
2.4 KiB
Nix
Raw Normal View History

2023-07-03 06:45:22 +02:00
{
config,
lib,
pkgs,
...
}: let
theme = pkgs.fetchzip {
2023-09-23 21:36:11 +02:00
url = "https://github.com/catppuccin/gitea/releases/download/v0.4.1/catppuccin-gitea.tar.gz";
sha256 = "sha256-14XqO1ZhhPS7VDBSzqW55kh6n5cFZGZmvRCtMEh8JPI=";
2023-07-03 06:45:22 +02:00
stripRoot = false;
};
in {
2023-07-03 03:33:11 +02:00
services.gitea = {
enable = true;
2023-08-01 18:41:40 +02:00
package = pkgs.unstable.gitea;
2023-07-05 21:41:15 +02:00
2023-07-03 03:33:11 +02:00
database = {
type = "postgres";
passwordFile = config.age.secrets."services/gitea/password-database".path;
};
lfs.enable = true;
appName = "nekowinston's Gitea";
settings = {
2023-07-03 21:25:18 +02:00
actions.ENABLED = true;
indexer = with config.services.elasticsearch; let
indexer = "elasticsearch";
2023-07-05 01:30:41 +02:00
conn = "http://${listenAddress}:${toString port}";
2023-07-03 21:25:18 +02:00
in {
ISSUE_INDEXER_CONN_STR = conn;
ISSUE_INDEXER_TYPE = indexer;
REPO_INDEXER_CONN_STR = conn;
REPO_INDEXER_ENABLED = true;
REPO_INDEXER_TYPE = indexer;
};
2023-07-03 06:45:22 +02:00
repository = {
ENABLE_PUSH_CREATE_USER = true;
};
2023-07-03 03:33:11 +02:00
server = rec {
DOMAIN = "git.winston.sh";
HTTP_ADDR = "127.0.0.1";
HTTP_PORT = 12492;
ROOT_URL = "https://${DOMAIN}/";
};
2023-07-03 06:45:22 +02:00
2023-07-03 03:33:11 +02:00
service.DISABLE_REGISTRATION = true;
2023-07-03 06:45:22 +02:00
session = {
COOKIE_SECURE = true;
SAME_SITE = "strict";
};
ui = {
THEMES =
builtins.concatStringsSep
","
(["auto"]
++ (map (name: lib.removePrefix "theme-" (lib.removeSuffix ".css" name))
(builtins.attrNames (builtins.readDir theme))));
2024-02-28 17:25:04 +01:00
DEFAULT_THEME = "catppuccin-frappe-pink";
2023-07-03 06:45:22 +02:00
};
2023-07-03 03:33:11 +02:00
};
};
2023-07-03 06:45:22 +02:00
networking.firewall.allowedTCPPorts = [22];
systemd.services.gitea = {
preStart = let
inherit (config.services.gitea) stateDir;
in
lib.mkAfter ''
2024-02-28 17:25:04 +01:00
rm -rf ${stateDir}/custom/public/assets
mkdir -p ${stateDir}/custom/public/assets
ln -sf ${theme} ${stateDir}/custom/public/assets/css
2023-07-03 06:45:22 +02:00
'';
};
2023-07-03 03:33:11 +02:00
age.secrets."services/gitea/password-database".owner = "gitea";
2023-07-03 21:25:18 +02:00
services.elasticsearch.enable = true;
2023-07-03 03:33:11 +02:00
services.nginx.virtualHosts.${config.services.gitea.settings.server.DOMAIN} = {
forceSSL = true;
enableACME = false;
useACMEHost = "winston.sh";
locations."/" = with config.services.gitea.settings.server; {
extraConfig = "client_max_body_size 512M;";
2023-07-05 01:30:41 +02:00
proxyPass = "http://${HTTP_ADDR}:${toString HTTP_PORT}";
2023-07-03 03:33:11 +02:00
};
};
}