feat: added syncthing

This commit is contained in:
Nick 2025-10-10 02:03:44 -05:00
parent 5da8744578
commit 5a5f7ed62d
4 changed files with 34 additions and 31 deletions

View file

@ -21,6 +21,7 @@ in
};
paths = {
path0 = "${varLib}/${name}";
path1 = "${varLib}/${name}/backups";
};
domains = {
url0 = domain;

View file

@ -6,16 +6,17 @@
}:
let
inherit (flake.config.machines.devices) ceres;
inherit (flake.config.services.instances)
smtp
forgejo
syncthing
web
inherit (flake.config.services)
instances
;
service = forgejo;
localhost = web.localhost.address0;
service = instances.forgejo;
localhost = instances.web.localhost.address0;
host = service.domains.url0;
backupPath = "${syncthing.paths.path0}/postgres-backups/${service.name}";
caddy = instances.caddy;
postgres = instances.postgresql;
syncthing = instances.syncthing;
backupPath = "${instances.syncthing.paths.path1}/${service.name}";
in
{
services = {
@ -51,11 +52,11 @@ in
};
mailer = {
ENABLED = true;
SMTP_ADDR = smtp.hostname;
SMTP_ADDR = instances.smtp.hostname;
FROM = service.email.address0;
USER = service.email.address0;
PROTOCOL = "smtp+starttls";
SMTP_PORT = smtp.ports.port0;
SMTP_PORT = instances.smtp.ports.port0;
SEND_AS_PLAIN_TEXT = true;
USE_CLIENT_CERT = false;
};
@ -117,13 +118,12 @@ in
systemd.tmpfiles.rules = [
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
"d ${backupPath} 0750 ${service.name} ${syncthing.name} -"
];
users.users.${service.name}.extraGroups = [
"caddy"
"postgres"
"syncthing"
caddy.name
postgres.name
syncthing.name
];
networking = {

View file

@ -8,7 +8,7 @@ let
;
service = instances.postgresql;
backupPath = "${instances.syncthing.paths.path0}/postgres-backups";
backupPath = "${instances.syncthing.paths.path1}/${service.name}";
in
{
services = {
@ -25,13 +25,6 @@ in
};
postgresql = {
enable = true;
# ensureDatabases = [ firefly-iii.name ];
# ensureUsers = [
# {
# name = firefly-iii.name;
# ensureDBOwnership = true;
# }
# ];
};
};
networking = {
@ -53,14 +46,11 @@ in
];
};
systemd.tmpfiles.rules = [
"d ${backupPath} 0750 ${service.name} ${instances.syncthing.name} -"
];
users.users.${service.name}.extraGroups = [
instances.nextcloud.name
instances.mastodon.name
instances.forgejo.name
instances.syncthing.name
];
system.activationScripts.postgresCommands = ''

View file

@ -6,13 +6,15 @@ let
mars
ceres
;
inherit (flake.config.services.instances)
syncthing
web
inherit (flake.config.services)
instances
;
hostname = config.networking.hostName;
localhost = web.localhost.address1;
service = syncthing;
localhost = instances.web.localhost.address1;
service = instances.syncthing;
postgres = instances.postgresql;
forgejo = instances.forgejo;
backupPath = "${service.paths.path1}";
syncDevices = {
synologySync = {
@ -59,6 +61,16 @@ in
};
};
systemd.tmpfiles.rules = [
# Main syncthing directory
"d ${service.paths.path0} 0755 ${service.name} ${service.name} -"
# Backup directories
"d ${backupPath} 0755 ${service.name} ${service.name} -"
"d ${backupPath}/${postgres.name} 0755 ${postgres.name} ${service.name} -"
"d ${backupPath}/${forgejo.name} 0750 ${forgejo.name} ${service.name} -"
];
networking = {
firewall = {
allowedTCPPorts = [