infra/nixos/hosts/silver/services/gitea.nix

73 lines
1.8 KiB
Nix
Raw Normal View History

2024-10-13 15:16:39 -05:00
{config, ...}: let
2024-11-03 20:30:30 -06:00
sshExposeIp = "107.152.41.67"; # TODO: hardcoding
2024-10-13 15:16:39 -05:00
sshIntPort = 14022;
httpIntPort = 14020;
2024-10-17 17:32:14 -05:00
dom = "git.min.rip"; # TODO: hardcoding
pBase = "/srv/gitea";
pGitea = "${pBase}/gitea";
pRunner = "${pBase}/runner";
2024-10-13 15:16:39 -05:00
in {
services.nginx = {
virtualHosts.${dom} = {
2024-10-13 18:14:29 -05:00
forceSSL = true;
enableACME = true;
2024-10-13 15:16:39 -05:00
locations."/" = {
proxyPass = "http://127.0.0.1:${toString httpIntPort}";
};
};
streamConfig = ''
upstream gitea {
server 127.0.0.1:${toString sshIntPort};
}
server {
listen ${sshExposeIp}:22;
proxy_timeout 20s;
proxy_pass gitea;
}
''; # May not support IPv6, i'm unsure..
};
# Auto-create directories we need
systemd.tmpfiles.rules = [
2024-10-17 17:32:14 -05:00
"d ${pBase} 0750 1000 1000 - -"
"d ${pGitea} 0750 1000 1000 - -"
"d ${pRunner} 0750 1000 1000 - -"
2024-10-13 15:16:39 -05:00
];
virtualisation.oci-containers.containers.gitea = {
image = "docker.io/gitea/gitea:1.21.4";
environment = {
USER_UID = "1000";
USER_GID = "1000";
GITEA_WORK_DIR = "/data/gitea";
GITEA_CUSTOM = "/data/gitea";
GITEA_APP_INI = "/data/gitea/conf/app.ini";
};
volumes = [
2024-10-17 17:32:14 -05:00
"${pGitea}:/data"
2024-10-13 15:16:39 -05:00
"/etc/localtime:/etc/localtime:ro"
];
ports = [
"${toString httpIntPort}:3000/tcp"
"${toString sshIntPort}:22/tcp"
];
};
sops.secrets."svc-gitea-runner-env" = {};
virtualisation.oci-containers.containers.gitea-runner = {
image = "docker.io/gitea/act_runner:0.2.6-dind-rootless";
environment = {
GITEA_INSTANCE_URL = "https://${dom}/";
DOCKER_HOST = "unix:///var/run/user/1000/docker.sock";
};
environmentFiles = [config.sops.secrets."svc-gitea-runner-env".path];
volumes = [
2024-10-17 17:32:14 -05:00
"${pRunner}:/data"
2024-10-13 15:16:39 -05:00
];
extraOptions = ["--privileged"];
};
}