nixos-config/machines/orbi/service-forgejo.nix

130 lines
3.2 KiB
Nix
Raw Normal View History

2024-08-29 03:26:04 +02:00
{
config,
lib,
pkgs,
components,
inputs,
2024-08-29 03:26:04 +02:00
...
}:
let
mysqlPort = 3333;
sshPort = 2222;
2024-10-24 10:37:59 +02:00
mysqlPackage = pkgs.mariadb;
forgejoPort = 3000;
in
2023-12-09 17:15:50 +01:00
{
healthchecks.http.forgejjo = {
2024-09-16 02:06:03 +02:00
url = "https://git.ingolf-wagner.de/explore/repos";
expectedContent = "palo/nixos-config";
};
healthchecks.closed.public.ports.forgejo = [
mysqlPort
forgejoPort
];
networking.firewall.allowedTCPPorts = [ sshPort ];
networking.firewall.allowedUDPPorts = [ sshPort ];
# todo : make a healthcheck on open ssh port
2023-12-09 17:15:50 +01:00
services.nginx = {
enable = true;
statusPage = true;
virtualHosts = {
"git.ingolf-wagner.de" = {
forceSSL = true;
enableACME = true;
locations."/" = {
2024-05-10 23:18:04 +02:00
proxyPass = "http://localhost:${toString config.services.forgejo.settings.server.HTTP_PORT}";
2023-12-09 17:15:50 +01:00
};
};
};
};
containers.forgejo = {
privateNetwork = false;
autoStart = true;
specialArgs = {
inherit components;
2023-12-09 17:15:50 +01:00
};
config =
{
config,
lib,
components,
...
}:
{
nixpkgs.pkgs = pkgs;
imports = [
"${components}/monitor/container.nix"
inputs.nix-topology.nixosModules.default
inputs.telemetry.nixosModules.telemetry
];
system.stateVersion = "24.11";
services.logrotate.checkConfig = false; # because uid 3000 does not exist in here
# ssh server (not really needed)
# ------------------------------
#services.openssh = {
# enable = true;
# ports = [ sshPort ];
# settings.X11Forwarding = false;
# settings.PasswordAuthentication = false;
#};
# forgejo
# -------
services.forgejo = {
enable = true;
package = pkgs.forgejo;
database = {
type = "mysql";
port = mysqlPort;
};
settings = {
server.SSH_PORT = sshPort;
server.START_SSH_SERVER = true;
server.HTTP_PORT = forgejoPort;
server.ROOT_URL = "https://git.ingolf-wagner.de/";
server.DOMAIN = "git.ingolf-wagner.de";
DEFAULT.APP_NAME = "git.ingolf-wagner.de";
service.DISABLE_REGISTRATION = true;
session.COOKIE_SECURE = true;
log.LEVEL = "Warn";
other = {
SHOW_FOOTER_VERSION = false;
};
};
};
# MySQL Database
# --------------
services.mysql = {
enable = true;
package = mysqlPackage;
settings.mysqld.port = mysqlPort;
ensureDatabases = [ config.services.forgejo.database.name ];
ensureUsers = [
{
name = config.services.forgejo.database.user;
ensurePermissions = {
"${config.services.forgejo.database.name}.*" = "ALL PRIVILEGES";
};
}
];
};
# Backup Database
# ---------------
services.mysqlBackup = {
enable = false;
databases = config.services.mysql.ensureDatabases;
singleTransaction = true;
};
};
2023-12-09 17:15:50 +01:00
};
}