mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-06-16 10:05:13 -05:00
feat: refactored abstractions
This commit is contained in:
parent
f3897c1e0c
commit
2e0ba5f89e
23 changed files with 324 additions and 310 deletions
|
@ -4,24 +4,23 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (flake.config.people) user0;
|
||||
inherit (flake.config.people.user.${user0}) domain email;
|
||||
inherit (flake.config.system.device) server wildcard;
|
||||
inherit (flake.config.service.instance) caddy peertube;
|
||||
localhost = wildcard.ip.address0;
|
||||
host = "${peertube.subdomain}.${domain.url1}";
|
||||
inherit (flake.config.system.device) server;
|
||||
inherit (flake.config.service.instance) caddy peertube web;
|
||||
service = peertube;
|
||||
localhost = web.localhost.address0;
|
||||
host = "${service.subdomain}.${web.domains.url1}";
|
||||
in {
|
||||
services = {
|
||||
peertube = {
|
||||
configureNginx = false;
|
||||
enable = true;
|
||||
enableWebHttps = true;
|
||||
group = peertube.name;
|
||||
group = service.name;
|
||||
listenWeb = caddy.ports.port1;
|
||||
listenHttp = peertube.ports.port0;
|
||||
listenHttp = service.ports.port0;
|
||||
localDomain = host;
|
||||
serviceEnvironmentFile = config.sops.secrets."${peertube.name}-root".path;
|
||||
user = peertube.name;
|
||||
serviceEnvironmentFile = config.sops.secrets."${service.name}-root".path;
|
||||
user = service.name;
|
||||
plugins = {
|
||||
enable = true;
|
||||
plugins = with pkgs; [
|
||||
|
@ -33,7 +32,7 @@ in {
|
|||
};
|
||||
|
||||
secrets = {
|
||||
secretsFile = config.sops.secrets."${peertube.name}-secret".path;
|
||||
secretsFile = config.sops.secrets."${service.name}-secret".path;
|
||||
};
|
||||
settings = {
|
||||
instance = {
|
||||
|
@ -45,25 +44,25 @@ in {
|
|||
smtp = {
|
||||
transport = "smtp";
|
||||
disable_starttls = false;
|
||||
from_address = email.address4;
|
||||
from_address = service.email.address0;
|
||||
hostname = "smtp.protonmail.ch";
|
||||
port = 587;
|
||||
username = email.address4;
|
||||
username = service.email.address0;
|
||||
tls = false;
|
||||
};
|
||||
};
|
||||
database = {
|
||||
createLocally = true;
|
||||
passwordFile = config.sops.secrets."${peertube.name}-database".path;
|
||||
passwordFile = config.sops.secrets."${service.name}-database".path;
|
||||
};
|
||||
redis = {
|
||||
enableUnixSocket = true;
|
||||
createLocally = true;
|
||||
passwordFile = config.sops.secrets."${peertube.name}-redis".path;
|
||||
passwordFile = config.sops.secrets."${service.name}-redis".path;
|
||||
};
|
||||
smtp = {
|
||||
createLocally = true;
|
||||
passwordFile = config.sops.secrets."${peertube.name}-smtp".path;
|
||||
passwordFile = config.sops.secrets."${service.name}-smtp".path;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -71,9 +70,9 @@ in {
|
|||
virtualHosts = {
|
||||
${host} = {
|
||||
extraConfig = ''
|
||||
reverse_proxy ${localhost}:${toString peertube.ports.port0}
|
||||
reverse_proxy ${localhost}:${toString service.ports.port0}
|
||||
|
||||
tls ${peertube.ssl.cert} ${peertube.ssl.key}
|
||||
tls ${service.ssl.cert} ${service.ssl.key}
|
||||
|
||||
'';
|
||||
};
|
||||
|
@ -84,43 +83,43 @@ in {
|
|||
sops = let
|
||||
sopsSecrets = ["smtp" "database" "redis" "root" "secret"];
|
||||
sopsPath = secret: {
|
||||
path = "${peertube.sops.path0}/${peertube.name}-${secret}-pass";
|
||||
owner = peertube.name;
|
||||
path = "${service.sops.path0}/${service.name}-${secret}-pass";
|
||||
owner = service.name;
|
||||
mode = "600";
|
||||
};
|
||||
in {
|
||||
secrets = builtins.listToAttrs (
|
||||
map
|
||||
(secret: {
|
||||
name = "${peertube.name}-${secret}";
|
||||
name = "${service.name}-${secret}";
|
||||
value = sopsPath secret;
|
||||
})
|
||||
sopsSecrets
|
||||
);
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/${peertube.name}" = {
|
||||
device = peertube.paths.path0;
|
||||
fileSystems."/var/lib/${service.name}" = {
|
||||
device = service.paths.path0;
|
||||
fsType = "none";
|
||||
options = ["bind"];
|
||||
depends = [server.storage0.mount];
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"Z ${peertube.paths.path0} 755 ${peertube.name} ${peertube.name} -"
|
||||
"Z ${peertube.sops.path0} 755 ${peertube.name} ${peertube.name} -"
|
||||
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
|
||||
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
|
||||
];
|
||||
|
||||
users.users.${peertube.name}.extraGroups = ["nginx" "caddy"];
|
||||
users.users.${service.name}.extraGroups = ["nginx" "caddy"];
|
||||
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedTCPPorts = [
|
||||
peertube.ports.port0
|
||||
peertube.ports.port1
|
||||
peertube.ports.port2
|
||||
peertube.ports.port3
|
||||
peertube.ports.port4
|
||||
service.ports.port0
|
||||
service.ports.port1
|
||||
service.ports.port2
|
||||
service.ports.port3
|
||||
service.ports.port4
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue