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

88 lines
2 KiB
Nix
Raw Normal View History

2025-06-27 01:37:33 -05:00
{ flake, config, ... }:
let
inherit (flake.config.people) user0;
2025-06-27 01:47:26 -05:00
inherit (flake.config.people.users.${user0}) email;
2025-06-27 01:37:33 -05:00
inherit (flake.config.services.instances) firefly web;
inherit (flake.config.machines.devices) ceres;
2025-06-27 01:56:14 -05:00
service = firefly;
2025-06-27 01:37:33 -05:00
localhost = web.localhost.address0;
host = service.domains.url0;
in
{
services = {
firefly-iii = {
enable = true;
virtualHost = host;
settings = {
APP_URL = host;
APP_KEY_FILE = config.sops.secrets."${service.name}-key".path;
2025-06-27 01:47:26 -05:00
SITE_OWNER = email.address0;
2025-06-27 01:37:33 -05:00
# DB_PORT = 3306;
DB_DATABASE = "firefly";
DB_USERNAME = "firefly";
DB_PASSWORD_FILE = config.sops.secrets."${service.name}-pass".path;
};
};
caddy = {
virtualHosts = {
"${host}" = {
extraConfig = ''
redir /.well-known/carddav /remote.php/dav/ 301
redir /.well-known/caldav /remote.php/dav/ 301
reverse_proxy ${localhost}:${toString service.ports.port0}
tls ${service.ssl.cert} ${service.ssl.key}
'';
};
};
};
};
2025-06-27 01:44:17 -05:00
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;
})
[
"key"
"pass"
]
);
};
2025-06-27 01:56:14 -05:00
# fileSystems."/var/lib/${service.name}" = {
# device = service.paths.path0;
# fsType = "none";
# options = [
# "bind"
# ];
# depends = [
# ceres.storage0.mount
# ];
# };
2025-06-27 01:37:33 -05:00
systemd.tmpfiles.rules = [
2025-06-27 01:56:14 -05:00
# "Z ${service.paths.path0} 755 ${service.name} ${service.name} -"
2025-06-27 01:37:33 -05:00
"Z ${service.sops.path0} 755 ${service.name} ${service.name} -"
];
networking = {
firewall = {
allowedTCPPorts = [
service.ports.port0
];
};
};
}