2024-08-06 19:52:19 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
name = "forgejo";
|
|
|
|
cfg = config.services.skynet."${name}";
|
|
|
|
|
|
|
|
domain_base = "${cfg.domain.base}.${cfg.domain.tld}";
|
|
|
|
domain_full = "${cfg.domain.sub}.${domain_base}";
|
|
|
|
in {
|
|
|
|
imports = [
|
|
|
|
];
|
|
|
|
|
|
|
|
options.services.skynet."${name}" = {
|
|
|
|
enable = mkEnableOption "Skynet Forgejo";
|
|
|
|
|
|
|
|
domain = {
|
|
|
|
tld = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "ie";
|
|
|
|
};
|
|
|
|
|
|
|
|
base = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "skynet";
|
|
|
|
};
|
|
|
|
|
|
|
|
sub = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
forgejo = {
|
2024-08-07 20:52:50 +00:00
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 3000;
|
|
|
|
};
|
2024-08-06 19:52:19 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-08-07 20:52:50 +00:00
|
|
|
# age.secrets.forgejo-mailer-password = {
|
|
|
|
# file = ../../secrets/forgejo/mailer-password.age;
|
|
|
|
# mode = "400";
|
|
|
|
# owner = "forgejo";
|
|
|
|
# };
|
2024-08-06 19:52:19 +00:00
|
|
|
|
|
|
|
services.skynet.acme.domains = [
|
|
|
|
"${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}"
|
|
|
|
];
|
|
|
|
|
|
|
|
# using https://nixos.org/manual/nixos/stable/index.html#module-services-gitlab as a guide
|
|
|
|
services.skynet.dns.records = [
|
|
|
|
{
|
|
|
|
record = cfg.domain.sub;
|
|
|
|
r_type = "CNAME";
|
|
|
|
value = config.services.skynet.host.name;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
# main site
|
|
|
|
"${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "skynet";
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://localhost:${toString cfg.forgejo.port}";
|
|
|
|
extraConfig = ''
|
|
|
|
client_max_body_size 1000M;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.forgejo = {
|
2024-08-07 20:52:50 +00:00
|
|
|
enable = true;
|
|
|
|
package = pkgs.forgejo;
|
|
|
|
database.type = "sqlite3";
|
|
|
|
# Enable support for Git Large File Storage
|
|
|
|
lfs.enable = true;
|
|
|
|
settings = {
|
|
|
|
server = {
|
|
|
|
DOMAIN = "${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}";
|
|
|
|
# You need to specify this to remove the port from URLs in the web UI.
|
|
|
|
ROOT_URL = "https://${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}/";
|
|
|
|
HTTP_PORT = cfg.forgejo.port;
|
2024-08-06 19:52:19 +00:00
|
|
|
};
|
2024-08-07 20:52:50 +00:00
|
|
|
|
|
|
|
# You can temporarily allow registration to create an admin user.
|
|
|
|
service.DISABLE_REGISTRATION = true;
|
|
|
|
# Add support for actions, based on act: https://github.com/nektos/act
|
2024-08-10 18:51:35 +00:00
|
|
|
actions = {
|
|
|
|
ENABLED = true;
|
|
|
|
DEFAULT_ACTIONS_URL = "github";
|
|
|
|
};
|
2024-08-07 20:52:50 +00:00
|
|
|
# Sending emails is completely optional
|
|
|
|
# You can send a test email from the web UI at:
|
|
|
|
# Profile Picture > Site Administration > Configuration > Mailer Configuration
|
|
|
|
# mailer = {
|
|
|
|
# ENABLED = true;
|
|
|
|
# SMTP_ADDR = "mail.${cfg.domain.base}.${cfg.domain.tld}";
|
|
|
|
# FROM = "noreply@${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}";
|
|
|
|
# USER = "noreply@${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}";
|
|
|
|
# };
|
2024-08-06 19:52:19 +00:00
|
|
|
};
|
2024-08-07 20:52:50 +00:00
|
|
|
# mailerPasswordFile = config.age.secrets.forgejo-mailer-password.path;
|
|
|
|
};
|
2024-08-06 19:52:19 +00:00
|
|
|
};
|
|
|
|
}
|