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
|
@ -3,12 +3,11 @@
|
|||
config,
|
||||
...
|
||||
}: 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.forgejo) paths ports name subdomain sops ssl;
|
||||
localhost = wildcard.ip.address0;
|
||||
host = "${subdomain}.${domain.url1}";
|
||||
inherit (flake.config.system.device) server;
|
||||
inherit (flake.config.service.instance) forgejo web;
|
||||
service = forgejo;
|
||||
localhost = web.localhost.address0;
|
||||
host = "${service.subdomain}.${web.domains.url1}";
|
||||
in {
|
||||
services = {
|
||||
forgejo = {
|
||||
|
@ -16,8 +15,8 @@ in {
|
|||
database.type = "postgres";
|
||||
lfs.enable = true;
|
||||
secrets = {
|
||||
mailer.PASSWD = config.sops.secrets."${name}-smtp".path;
|
||||
database.PASSWD = config.sops.secrets."${name}-database".path;
|
||||
mailer.PASSWD = config.sops.secrets."${service.name}-smtp".path;
|
||||
database.PASSWD = config.sops.secrets."${service.name}-database".path;
|
||||
};
|
||||
dump = {
|
||||
interval = "5:00";
|
||||
|
@ -29,7 +28,7 @@ in {
|
|||
server = {
|
||||
DOMAIN = host;
|
||||
ROOT_URL = "https://${host}/";
|
||||
HTTP_PORT = ports.port0;
|
||||
HTTP_PORT = service.ports.port0;
|
||||
};
|
||||
# If you need to start from scratch, don't forget to turn this off again
|
||||
service.DISABLE_REGISTRATION = false;
|
||||
|
@ -43,8 +42,8 @@ in {
|
|||
mailer = {
|
||||
ENABLED = true;
|
||||
SMTP_ADDR = "smtp.protonmail.ch";
|
||||
FROM = email.address5;
|
||||
USER = email.address5;
|
||||
FROM = service.email.address0;
|
||||
USER = service.email.address0;
|
||||
PROTOCOL = "smtp+starttls";
|
||||
SMTP_PORT = 587;
|
||||
SEND_AS_PLAIN_TEXT = true;
|
||||
|
@ -56,9 +55,9 @@ in {
|
|||
virtualHosts = {
|
||||
"${host}" = {
|
||||
extraConfig = ''
|
||||
reverse_proxy ${localhost}:${toString ports.port0}
|
||||
reverse_proxy ${localhost}:${toString service.ports.port0}
|
||||
|
||||
tls ${ssl.cert} ${ssl.key}
|
||||
tls ${service.ssl.cert} ${service.ssl.key}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
@ -67,39 +66,39 @@ in {
|
|||
sops = let
|
||||
sopsSecrets = ["smtp" "database"];
|
||||
sopsPath = secret: {
|
||||
path = "${sops.path0}/${name}-${secret}";
|
||||
owner = name;
|
||||
path = "${service.sops.path0}/${service.name}-${secret}";
|
||||
owner = service.name;
|
||||
mode = "600";
|
||||
};
|
||||
in {
|
||||
secrets = builtins.listToAttrs (
|
||||
map
|
||||
(secret: {
|
||||
name = "${name}-${secret}";
|
||||
name = "${service.name}-${secret}";
|
||||
value = sopsPath secret;
|
||||
})
|
||||
sopsSecrets
|
||||
);
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/${name}" = {
|
||||
device = paths.path0;
|
||||
fileSystems."/var/lib/${service.name}" = {
|
||||
device = service.paths.path0;
|
||||
fsType = "none";
|
||||
options = ["bind"];
|
||||
depends = [server.storage0.mount];
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"Z ${paths.path0} 755 ${name} ${name} -"
|
||||
"Z ${sops.path0} 755 ${name} ${name} -"
|
||||
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
|
||||
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
|
||||
];
|
||||
|
||||
users.users.${name}.extraGroups = ["caddy" "postgres"];
|
||||
users.users.${service.name}.extraGroups = ["caddy" "postgres"];
|
||||
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedTCPPorts = [
|
||||
ports.port0
|
||||
service.ports.port0
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue