infra/config/services/gitea.nix

115 lines
3 KiB
Nix
Raw Normal View History

2023-07-03 06:45:22 +02:00
{
config,
lib,
inputs,
2023-07-03 06:45:22 +02:00
pkgs,
...
2024-03-03 00:24:08 +01:00
}: {
# swap out Gitea stable for unstable
2024-03-07 22:16:02 +01:00
disabledModules = [
"services/misc/gitea.nix"
"services/continuous-integration/gitea-actions-runner.nix"
];
imports = [
"${inputs.nixpkgs-unstable}/nixos/modules/services/misc/gitea.nix"
"${inputs.nixpkgs-unstable}/nixos/modules/services/continuous-integration/gitea-actions-runner.nix"
];
services.gitea.package = pkgs.unstable.gitea;
2024-03-07 22:16:02 +01:00
services.gitea-actions-runner.package = pkgs.unstable.gitea-actions-runner;
age.secrets."services/gitea/password-database".owner = "gitea";
networking.firewall.allowedTCPPorts = [22];
services.elasticsearch.enable = true;
2023-07-03 03:33:11 +02:00
services.gitea = {
enable = true;
appName = "winston's 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;
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 {
REPO_INDEXER_ENABLED = true;
REPO_INDEXER_CONN_STR = conn;
2023-07-03 21:25:18 +02:00
REPO_INDEXER_TYPE = indexer;
ISSUE_INDEXER_CONN_STR = conn;
ISSUE_INDEXER_TYPE = indexer;
2023-07-03 21:25:18 +02:00
};
2023-07-03 06:45:22 +02:00
repository.ENABLE_PUSH_CREATE_USER = true;
2023-07-03 06:45:22 +02:00
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";
};
2024-03-03 00:24:08 +01:00
"ui.meta" = {
AUTHOR = "nekowinston";
DESCRIPTION = "winston's gitea instance";
};
other = {
SHOW_FOOTER_VERSION = false;
SHOW_FOOTER_TEMPLATE_LOAD_TIME = false;
SHOW_FOOTER_BRANDING = false;
2023-07-03 06:45:22 +02:00
};
2023-07-03 03:33:11 +02:00
};
};
2024-03-07 22:16:02 +01:00
services.gitea-actions-runner.instances.main = {
enable = true;
name = "main";
url = config.services.gitea.settings.server.ROOT_URL;
tokenFile = config.age.secrets."services/gitea/runner-token".path;
labels = ["ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-latest"];
2024-03-07 22:51:41 +01:00
settings.container = {
network = "host";
options = "--add-host=git.winston.sh:host-gateway";
2024-03-07 22:58:42 +01:00
env_file = config.age.secrets."services/gitea/runner.env".path;
2024-03-07 22:51:41 +01:00
};
};
2024-03-03 00:24:08 +01:00
systemd.services.gitea.preStart = let
inherit (config.services.gitea) stateDir;
in
lib.mkAfter ''
chmod u+w -R ${stateDir}/custom/**/*
# apply customizations
cp -Rf ${./gitea}/* ${stateDir}/custom
chmod u-w -R ${stateDir}/custom/**/*
'';
2023-07-03 06:45:22 +02:00
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
};
};
}