2024-11-20 00:58:57 -05:00
|
|
|
{ config, lib, ... }:
|
2024-11-20 02:23:20 -05:00
|
|
|
let
|
|
|
|
cfg = config.aether.forgejo;
|
|
|
|
forgejo = config.services.forgejo;
|
|
|
|
srv = forgejo.settings.server;
|
2024-11-22 18:54:57 -05:00
|
|
|
|
|
|
|
useSubdomain = !(builtins.isNull cfg.subdomain);
|
2024-11-20 02:23:20 -05:00
|
|
|
in {
|
|
|
|
imports = [ ./options.nix ];
|
|
|
|
|
|
|
|
# Web server
|
|
|
|
|
|
|
|
services.nginx.enable = true;
|
|
|
|
services.nginx.virtualHosts.${srv.DOMAIN} = {
|
|
|
|
forceSSL = config.aether.https;
|
|
|
|
enableACME = config.aether.https;
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 512M;
|
|
|
|
'';
|
|
|
|
locations."/".proxyPass = "http://localhost:${builtins.toString srv.HTTP_PORT}";
|
|
|
|
};
|
2024-11-20 00:58:57 -05:00
|
|
|
|
2024-11-20 02:23:20 -05:00
|
|
|
security.acme.acceptTerms = config.aether.https;
|
|
|
|
security.acme.defaults.email = cfg.acmeEmail;
|
2024-11-20 00:58:57 -05:00
|
|
|
|
2024-11-20 02:23:20 -05:00
|
|
|
networking.firewall.allowedTCPPorts =
|
2024-11-22 18:56:46 -05:00
|
|
|
[ 80 443 ];
|
2024-11-20 00:58:57 -05:00
|
|
|
|
2024-11-20 02:23:20 -05:00
|
|
|
# Forgejo
|
2024-11-20 00:58:57 -05:00
|
|
|
|
2024-11-20 02:23:20 -05:00
|
|
|
services.forgejo = {
|
|
|
|
enable = true;
|
|
|
|
user = cfg.user;
|
|
|
|
group = forgejo.user;
|
|
|
|
database.user = forgejo.user;
|
2024-11-20 00:58:57 -05:00
|
|
|
|
2024-11-20 02:23:20 -05:00
|
|
|
settings.server = {
|
2024-11-22 18:54:57 -05:00
|
|
|
DOMAIN = lib.optionalString useSubdomain "${cfg.subdomain}."
|
2024-11-20 02:23:20 -05:00
|
|
|
+ config.aether.domain;
|
|
|
|
ROOT_URL = "https://${srv.DOMAIN}/";
|
2024-11-20 00:58:57 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-11-20 02:23:20 -05:00
|
|
|
systemd.tmpfiles.rules =
|
2024-11-22 18:54:57 -05:00
|
|
|
lib.optional useSubdomain
|
2024-11-22 18:56:17 -05:00
|
|
|
"L+ ${forgejo.stateDir}/custom/templates - - - - ${cfg.templates}";
|
2024-11-20 02:23:20 -05:00
|
|
|
}
|
|
|
|
// lib.mkIf cfg.createUser {
|
|
|
|
users.users.${forgejo.user} = {
|
|
|
|
home = forgejo.stateDir;
|
|
|
|
useDefaultShell = true;
|
|
|
|
group = forgejo.group;
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
users.groups.${forgejo.group} = {};
|
2024-11-20 00:58:57 -05:00
|
|
|
}
|