aether/modules/forgejo/default.nix

56 lines
1.3 KiB
Nix
Raw Permalink Normal View History

{ config, lib, ... }:
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);
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}";
};
security.acme.acceptTerms = config.aether.https;
security.acme.defaults.email = cfg.acmeEmail;
networking.firewall.allowedTCPPorts = [ 80 443 ];
# Forgejo
services.forgejo = {
enable = true;
user = cfg.user;
group = forgejo.user;
database.user = forgejo.user;
settings.server = {
2024-11-22 18:54:57 -05:00
DOMAIN = lib.optionalString useSubdomain "${cfg.subdomain}."
+ config.aether.domain;
ROOT_URL = "https://${srv.DOMAIN}/";
};
};
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}";
}
// lib.mkIf cfg.createUser {
users.users.${forgejo.user} = {
home = forgejo.stateDir;
useDefaultShell = true;
group = forgejo.group;
isSystemUser = true;
};
users.groups.${forgejo.group} = {};
}