dotfiles/modules/nixos/services/firefly-iii/default.nix

103 lines
2.5 KiB
Nix
Raw Normal View History

2025-10-09 03:08:30 -05:00
{ flake, config, ... }:
2025-10-09 02:56:01 -05:00
let
2025-10-20 19:37:05 -05:00
inherit (flake.config.services.instances) firefly-iii smtp;
inherit (flake.config.people) user0;
inherit (flake.config.people.users.${user0}) email;
2025-10-09 03:08:30 -05:00
inherit (flake.config.machines.devices) ceres;
2025-10-09 03:49:09 -05:00
host = service.domains.url0;
2025-10-09 03:28:19 -05:00
service = firefly-iii;
2025-10-09 02:56:01 -05:00
in
{
services = {
firefly-iii = {
enable = true;
dataDir = service.paths.path0;
2025-10-09 04:09:41 -05:00
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;
};
2025-10-09 02:57:02 -05:00
settings = {
2025-10-09 05:41:34 -05:00
DB_CONNECTION = "pgsql";
2025-10-09 04:43:59 -05:00
APP_URL = "https://${host}";
2025-10-09 03:08:30 -05:00
APP_KEY_FILE = config.sops.secrets."${service.name}-pass".path;
2025-10-09 05:41:34 -05:00
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";
2025-10-20 19:37:05 -05:00
SITE_OWNER = email.address2;
2025-10-09 02:57:02 -05:00
};
2025-10-09 02:56:01 -05:00
};
firefly-iii-data-importer = {
enable = true;
};
2025-10-09 03:49:09 -05:00
caddy = {
virtualHosts = {
${host} = {
extraConfig = ''
2025-10-09 04:06:17 -05:00
root * ${config.services.firefly-iii.package}/public
2025-10-09 05:41:34 -05:00
file_server
2025-10-09 22:47:13 -05:00
encode gzip
php_fastcgi unix//run/phpfpm/firefly-iii.sock
2025-10-09 03:49:09 -05:00
tls ${service.ssl.cert} ${service.ssl.key}
'';
2025-10-09 22:47:13 -05:00
2025-10-09 03:49:09 -05:00
};
};
};
2025-10-09 02:56:01 -05:00
};
2025-10-09 03:08:30 -05:00
sops =
let
sopsPath = secret: {
path = "${service.sops.path0}/${service.name}-${secret}";
2025-10-09 03:28:19 -05:00
owner = service.name;
2025-10-09 03:08:30 -05:00
mode = "600";
};
in
{
secrets = builtins.listToAttrs (
map
(secret: {
2025-10-09 03:09:57 -05:00
name = "${service.name}-${secret}";
2025-10-09 03:08:30 -05:00
value = sopsPath secret;
})
[
"pass"
2025-10-09 04:15:49 -05:00
"data"
2025-10-20 19:37:05 -05:00
"smtp"
2025-10-09 03:08:30 -05:00
]
);
};
2025-10-09 05:41:34 -05:00
fileSystems."/var/lib/${service.name}" = {
device = service.paths.path0;
fsType = "none";
options = [
"bind"
];
depends = [
ceres.storage0.mount
];
};
2025-10-09 03:08:30 -05:00
systemd.tmpfiles.rules = [
2025-10-09 05:18:47 -05:00
"Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
2025-10-09 03:08:30 -05:00
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
];
2025-10-09 02:56:01 -05:00
networking = {
firewall.allowedTCPPorts = [
8080
8081
];
};
}