infrastructure/config/services/gitea/default.nix
2021-08-08 14:57:13 +01:00

81 lines
2.1 KiB
Nix

{ config, pkgs, tf, ... }:
{
services.postgresql = {
enable = true;
ensureDatabases = [ "gitea" ];
ensureUsers = [{
name = "gitea";
ensurePermissions."DATABASE gitea" = "ALL PRIVILEGES";
}];
};
deploy.tf.variables.gitea_mail = {
type = "string";
value.shellCommand = "bitw get infra/gitea-mail -f password";
};
secrets.files.gitea_mail = {
text = ''
${tf.variables.gitea_mail.ref};
'';
owner = "gitea";
group = "gitea";
};
services.gitea = {
enable = true;
disableRegistration = true;
domain = "git.${config.kw.dns.domain}";
rootUrl = "https://git.${config.kw.dns.domain}";
httpAddress = "127.0.0.1";
appName = "kittywitch git";
ssh = { clonePort = 62954; };
database = {
type = "postgres";
name = "gitea";
user = "gitea";
};
mailerPasswordFile = config.secrets.files.gitea_mail.path;
settings = {
security = { DISABLE_GIT_HOOKS = false; };
api = { ENABLE_SWAGGER = true; };
mailer = {
ENABLED = true;
SUBJECT = "%(APP_NAME)s";
HOST = "athame.kittywit.ch:465";
USER = "gitea@kittywit.ch";
#SEND_AS_PLAIN_TEXT = true;
USE_SENDMAIL = false;
FROM = "\"kittywitch git\" <gitea@${config.kw.dns.domain}>";
};
service = {
NO_REPLY_ADDRESS = "kittywit.ch";
REGISTER_EMAIL_CONFIRM = true;
ENABLE_NOTIFY_MAIL = true;
};
ui = {
THEMES = "gitea,arc-green";
DEFAULT_THEME = "gitea";
THEME_COLOR_META_TAG = "#222222";
};
};
};
systemd.services.gitea.preStart = ''
${pkgs.coreutils}/bin/ln -sfT ${./public} /var/lib/gitea/custom/public
${pkgs.coreutils}/bin/ln -sfT ${./templates} /var/lib/gitea/custom/templates
'';
services.nginx.virtualHosts."git.${config.kw.dns.domain}" = {
enableACME = true;
forceSSL = true;
locations = { "/".proxyPass = "http://127.0.0.1:3000"; };
};
deploy.tf.dns.records.kittywitch_git = {
tld = config.kw.dns.tld;
domain = "git";
cname.target = "${config.networking.hostName}.${config.kw.dns.tld}";
};
}