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

101 lines
2.4 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-09 03:28:19 -05:00
inherit (flake.config.services.instances) firefly-iii;
2025-10-09 03:08:30 -05:00
inherit (flake.config.machines.devices) ceres;
2025-10-09 03:49:09 -05:00
# localhost = "${ceres.ip.addess0}:${service.ports.port0}";
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 05:18:47 -05:00
virtualHost = host;
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 = {
DB_CONNECTION = "pgsql";
2025-10-09 05:08:22 -05:00
DB_HOST = "localhost";
2025-10-09 05:09:12 -05:00
DB_PORT = 5432;
2025-10-09 05:08:22 -05:00
DB_DATABASE = service.name;
DB_USERNAME = service.name;
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 04:15:49 -05:00
DB_PASSWORD_FILE = config.sops.secrets."${service.name}-data".path;
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
encode gzip
2025-10-09 05:08:22 -05:00
php_fastcgi unix//run/phpfpm/firefly-iii.sock {
2025-10-09 04:06:17 -05:00
try_files {path} /index.php?{query}
trusted_proxies private_ranges
2025-10-09 03:51:11 -05:00
}
2025-10-09 04:06:17 -05:00
file_server
2025-10-09 03:49:09 -05:00
tls ${service.ssl.cert} ${service.ssl.key}
'';
};
};
};
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-09 03:08:30 -05:00
]
);
};
2025-10-09 05:12:19 -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
2025-10-09 05:09:24 -05:00
5432
2025-10-09 02:56:01 -05:00
];
};
}