Files
infra/lib/modules/gitea/default.nix
2023-10-01 12:35:30 +02:00

73 lines
1.9 KiB
Nix

{config, pkgs, lib, ...}:
let
cfg = config.services.gitea;
domain = "source.ctsk.dev";
port = 10010;
in {
services.gitea = {
stateDir = "/srv/gitea";
appName = "WITHOUT WARRANTY OF ANY KIND";
database = {
type = "sqlite3";
};
settings = {
server = {
ROOT_URL = "https://${domain}";
HTTP_ADDRESS = "127.0.0.1";
HTTP_PORT = port;
SSH_USER = "git";
SSH_PORT = 2324;
LANDING_PAGE = "explore";
};
service = {
DISABLE_REGISTRATION = true;
DISABLE_USERS_PAGE = true;
};
repository = {
ENABLE_PUSH_CREATE_USER = true;
DISABLE_STARS = true;
DISABLED_REPO_UNITS = "repo.wiki,repo.projects,repo.pulls";
DEFAULT_REPO_UNITS = "repo.code,repo.issues,repo.releases";
};
indexer = {
REPO_INDEXER_ENABLED = true;
REPO_INDEXER_EXCLUDE = "**.pdf, **.png, **.jpeg, **.jpm, **.svg, **.webm";
};
metrics.ENABLED = true;
};
};
services.nginx.virtualHosts."${domain}" = {
forceSSL = true;
enableACME = true;
locations."/metrics".extraConfig = ''
allow 127.0.0.1;
deny all;
'';
locations."/".proxyPass = "http://127.0.0.1:${toString port}";
};
services.prometheus.scrapeConfigs = lib.mkIf config.services.prometheus.enable [
{
job_name = "gitea";
static_configs = [{
targets = [ "127.0.0.1:${toString port}" ];
}];
}
];
systemd.tmpfiles.rules = [
''L+ ${cfg.stateDir}/custom/public/img/logo.svg - - - - ${pkgs.logo.svg}''
''L+ ${cfg.stateDir}/custom/public/img/logo.png - - - - ${pkgs.logo.png."512x512"}''
''L+ ${cfg.stateDir}/custom/public/img/favicon.svg - - - - ${pkgs.logo.svg}''
''L+ ${cfg.stateDir}/custom/public/img/favicon.png - - - - ${pkgs.logo.png."256x256"}''
''L+ ${cfg.stateDir}/custom/templates - - - - ${./templates}''
];
environment.systemPackages = [ pkgs.gitea ];
}