{ config, lib, pkgs, ... }: { options.sysconfig.opts.virtualization.gitea.enable = lib.options.mkOption { type = lib.types.bool; default = false; }; config = lib.mkIf config.sysconfig.opts.virtualization.gitea.enable { sops.secrets = { "gitea/db_pass" = {}; }; services.openssh.ports = [ 2222 ]; networking.firewall.allowedTCPPorts = [ 22 2222 ]; containers.gitea = { autoStart = true; privateNetwork = true; hostAddress = "192.168.100.10"; localAddress = "192.168.100.20"; forwardPorts = [ { containerPort = 22; hostPort = 22; } ]; bindMounts = { "/etc/gitea/data" = { hostPath = "/ssd1/Gitea/data"; isReadOnly = false; }; }; extraFlags = [ "--load-credential=dbpass:${config.sops.secrets."gitlab/db_pass".path}" ]; config = { systemd.services.secrets_setup = { wantedBy = [ "gitea.service" ]; serviceConfig = { LoadCredential = [ "dbpass" ]; }; script = '' cat ''${CREDENTIALS_DIRECTORY}/dbpass > /etc/gitea/dbpass chown gitea:gitea /etc/gitea/* ''; }; services.gitea = { enable = true; stateDir = "/etc/gitea/data"; dump.enable = true; appName = "Gitea"; settings = { server = { DOMAIN = "gitea.blunkall.us"; HTTP_PORT = 3000; ROOT_URL = "https://gitea.blunkall.us/"; }; service = { DISABLE_REGISTRATION = false; ALLOW_ONLY_EXTERNAL_REGISTRATION = true; }; oauth2_client = { ENABLE_AUTO_REGISTRATION = true; }; session.COOKIE_SECURE = true; }; database = { passwordFile = "/etc/gitea/dbpass"; type = "postgres"; }; }; services.openssh.enable = true; networking.firewall.allowedTCPPorts = [ 22 3000 ]; system.stateVersion = "24.11"; }; }; }; }