mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-06 21:17:14 -06:00
102 lines
2.5 KiB
Nix
Executable file
102 lines
2.5 KiB
Nix
Executable file
{ flake, config, ... }:
|
|
let
|
|
inherit (flake.config.services.instances) firefly-iii smtp;
|
|
inherit (flake.config.people) user0;
|
|
inherit (flake.config.people.users.${user0}) email;
|
|
inherit (flake.config.machines.devices) ceres;
|
|
host = service.domains.url0;
|
|
service = firefly-iii;
|
|
in
|
|
{
|
|
services = {
|
|
firefly-iii = {
|
|
enable = true;
|
|
dataDir = service.paths.path0;
|
|
poolConfig = {
|
|
"listen.owner" = config.services.caddy.user;
|
|
"pm" = "dynamic";
|
|
"pm.max_children" = 32;
|
|
"pm.start_servers" = 2;
|
|
"pm.min_spare_servers" = 2;
|
|
"pm.max_spare_servers" = 4;
|
|
"pm.max_requests" = 500;
|
|
};
|
|
settings = {
|
|
DB_CONNECTION = "pgsql";
|
|
APP_URL = "https://${host}";
|
|
APP_KEY_FILE = config.sops.secrets."${service.name}-pass".path;
|
|
DB_PASSWORD_FILE = config.sops.secrets."${service.name}-data".path;
|
|
MAIL_MAILER = smtp.name;
|
|
MAIL_HOST = smtp.hostname;
|
|
MAIL_PORT = smtp.ports.port0;
|
|
MAIL_FROM = smtp.email.address0;
|
|
MAIL_USERNAME = smtp.email.address0;
|
|
MAIL_PASSWORD_FILE = config.sops.secrets."${service.name}-smtp".path;
|
|
MAIL_ENCRYPTION = "tls";
|
|
SITE_OWNER = email.address2;
|
|
};
|
|
};
|
|
firefly-iii-data-importer = {
|
|
enable = true;
|
|
};
|
|
caddy = {
|
|
virtualHosts = {
|
|
${host} = {
|
|
extraConfig = ''
|
|
root * ${config.services.firefly-iii.package}/public
|
|
file_server
|
|
encode gzip
|
|
php_fastcgi unix//run/phpfpm/firefly-iii.sock
|
|
tls ${service.ssl.cert} ${service.ssl.key}
|
|
'';
|
|
|
|
};
|
|
};
|
|
};
|
|
};
|
|
sops =
|
|
let
|
|
sopsPath = secret: {
|
|
path = "${service.sops.path0}/${service.name}-${secret}";
|
|
owner = service.name;
|
|
mode = "600";
|
|
};
|
|
in
|
|
{
|
|
secrets = builtins.listToAttrs (
|
|
map
|
|
(secret: {
|
|
name = "${service.name}-${secret}";
|
|
value = sopsPath secret;
|
|
})
|
|
[
|
|
"pass"
|
|
"data"
|
|
"smtp"
|
|
]
|
|
);
|
|
};
|
|
|
|
fileSystems."/var/lib/${service.name}" = {
|
|
device = service.paths.path0;
|
|
fsType = "none";
|
|
options = [
|
|
"bind"
|
|
];
|
|
depends = [
|
|
ceres.storage0.mount
|
|
];
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
|
|
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
|
|
];
|
|
|
|
networking = {
|
|
firewall.allowedTCPPorts = [
|
|
8080
|
|
8081
|
|
];
|
|
};
|
|
}
|