2024-10-06 15:25:05 -05:00
|
|
|
{
|
|
|
|
flake,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
2024-11-04 20:49:43 -06:00
|
|
|
inherit (flake.config.machines.devices) server;
|
|
|
|
inherit (flake.config.services.instances) caddy peertube web;
|
2024-10-19 18:22:29 -05:00
|
|
|
service = peertube;
|
|
|
|
localhost = web.localhost.address0;
|
2024-12-19 20:06:05 -06:00
|
|
|
host = "${service.subdomain}.${web.domains.url3}";
|
2024-10-06 15:25:05 -05:00
|
|
|
in {
|
|
|
|
services = {
|
|
|
|
peertube = {
|
|
|
|
configureNginx = false;
|
|
|
|
enable = true;
|
|
|
|
enableWebHttps = true;
|
2024-10-19 18:22:29 -05:00
|
|
|
group = service.name;
|
2024-10-06 15:25:05 -05:00
|
|
|
listenWeb = caddy.ports.port1;
|
2024-10-19 18:22:29 -05:00
|
|
|
listenHttp = service.ports.port0;
|
2024-10-06 15:25:05 -05:00
|
|
|
localDomain = host;
|
2024-10-19 18:22:29 -05:00
|
|
|
serviceEnvironmentFile = config.sops.secrets."${service.name}-root".path;
|
|
|
|
user = service.name;
|
2024-10-06 15:25:05 -05:00
|
|
|
plugins = {
|
|
|
|
enable = true;
|
2024-11-04 19:24:06 -06:00
|
|
|
plugins = builtins.attrValues {
|
|
|
|
inherit
|
|
|
|
(pkgs)
|
|
|
|
peertube-plugin-livechat
|
|
|
|
peertube-plugin-matomo
|
|
|
|
peertube-plugin-transcoding-custom-quality
|
|
|
|
peertube-theme-dark
|
|
|
|
;
|
|
|
|
};
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
secrets = {
|
2024-10-19 18:22:29 -05:00
|
|
|
secretsFile = config.sops.secrets."${service.name}-secret".path;
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
settings = {
|
|
|
|
instance = {
|
2024-12-13 16:21:25 -06:00
|
|
|
name = "upRootNutrition";
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
log = {
|
|
|
|
level = "debug";
|
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
transport = "smtp";
|
|
|
|
disable_starttls = false;
|
2024-10-19 18:22:29 -05:00
|
|
|
from_address = service.email.address0;
|
2024-10-06 15:25:05 -05:00
|
|
|
hostname = "smtp.protonmail.ch";
|
|
|
|
port = 587;
|
2024-10-19 18:22:29 -05:00
|
|
|
username = service.email.address0;
|
2024-10-06 15:25:05 -05:00
|
|
|
tls = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
database = {
|
|
|
|
createLocally = true;
|
2024-10-19 18:22:29 -05:00
|
|
|
passwordFile = config.sops.secrets."${service.name}-database".path;
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
redis = {
|
|
|
|
enableUnixSocket = true;
|
|
|
|
createLocally = true;
|
2024-10-19 18:22:29 -05:00
|
|
|
passwordFile = config.sops.secrets."${service.name}-redis".path;
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
createLocally = true;
|
2024-10-19 18:22:29 -05:00
|
|
|
passwordFile = config.sops.secrets."${service.name}-smtp".path;
|
2024-10-06 15:25:05 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
caddy = {
|
|
|
|
virtualHosts = {
|
|
|
|
${host} = {
|
|
|
|
extraConfig = ''
|
2024-10-19 18:22:29 -05:00
|
|
|
reverse_proxy ${localhost}:${toString service.ports.port0}
|
2024-10-06 15:25:05 -05:00
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
2024-10-06 15:25:05 -05:00
|
|
|
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
sops = let
|
|
|
|
sopsPath = secret: {
|
2024-10-19 18:22:29 -05:00
|
|
|
path = "${service.sops.path0}/${service.name}-${secret}-pass";
|
|
|
|
owner = service.name;
|
2024-10-06 15:25:05 -05:00
|
|
|
mode = "600";
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
secrets = builtins.listToAttrs (
|
|
|
|
map
|
|
|
|
(secret: {
|
2024-10-19 18:22:29 -05:00
|
|
|
name = "${service.name}-${secret}";
|
2024-10-06 15:25:05 -05:00
|
|
|
value = sopsPath secret;
|
|
|
|
})
|
2024-11-04 02:09:15 -06:00
|
|
|
[
|
|
|
|
"smtp"
|
|
|
|
"database"
|
|
|
|
"redis"
|
|
|
|
"root"
|
|
|
|
"secret"
|
|
|
|
]
|
2024-10-06 15:25:05 -05:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
|
|
device = service.paths.path0;
|
2024-10-06 15:25:05 -05:00
|
|
|
fsType = "none";
|
|
|
|
options = ["bind"];
|
|
|
|
depends = [server.storage0.mount];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
2024-10-19 18:22:29 -05:00
|
|
|
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
|
|
|
|
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
|
2024-10-06 15:25:05 -05:00
|
|
|
];
|
|
|
|
|
2024-10-19 18:22:29 -05:00
|
|
|
users.users.${service.name}.extraGroups = ["nginx" "caddy"];
|
2024-10-06 15:25:05 -05:00
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [
|
2024-10-19 18:22:29 -05:00
|
|
|
service.ports.port0
|
|
|
|
service.ports.port1
|
|
|
|
service.ports.port2
|
|
|
|
service.ports.port3
|
|
|
|
service.ports.port4
|
2024-10-06 15:25:05 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|