dotfiles/nixos/modules/services/peertube.nix

152 lines
3.3 KiB
Nix
Raw Normal View History

2024-10-06 15:25:05 -05:00
{
flake,
config,
pkgs,
...
2025-01-18 22:17:14 -06:00
}:
let
inherit (flake.config.machines.devices)
2025-01-08 19:06:14 -06:00
server
;
2025-01-18 22:17:14 -06:00
inherit (flake.config.services.instances)
2025-01-08 19:06:14 -06:00
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}";
2025-01-18 22:17:14 -06:00
in
{
2024-10-06 15:25:05 -05:00
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;
2025-01-18 22:17:14 -06:00
# plugins = {
# enable = true;
# 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
'';
};
};
};
};
2025-01-18 22:17:14 -06:00
sops =
let
sopsPath = secret: {
path = "${service.sops.path0}/${service.name}-${secret}-pass";
owner = service.name;
mode = "600";
};
in
{
secrets = builtins.listToAttrs (
map
(secret: {
name = "${service.name}-${secret}";
value = sopsPath secret;
})
[
"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";
2025-01-08 19:06:14 -06:00
options = [
"bind"
];
2025-01-08 19:11:58 -06:00
depends = [
server.storage0.mount
];
2024-10-06 15:25:05 -05:00
};
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
];
2025-01-08 19:11:58 -06: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
];
};
};
}