CrOS/modules/quadlets/flamesites/default.nix
2026-03-22 16:20:59 -04:00

71 lines
2.1 KiB
Nix

{
pkgs,
inputs,
...
}:
let
volumePath = "/overseer/services";
swPort = lib.custom.autoport "swgalaxysite";
bandPort = lib.custom.autoport "flamebandsite";
in
{
systemd.tmpfiles.rules = [
"d ${volumePath}/flamesites 0750 crow"
"d ${volumePath}/flamesites/swgalaxyproject 0750 crow"
"d ${volumePath}/flamesites/nnsbluegrass 0750 crow"
"d ${volumePath}/flamesites/swgalaxyproject/dbBackups 0750 crow"
"d ${volumePath}/flamesites/nnsbluegrass/dbBackups 0750 crow"
];
systemd.timers.flamesite-backup = {
enable = true;
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "1hr";
OnUnitActiveSec = "1hr";
Unit = "flamesite-backup.service";
};
};
systemd.services.flamesite-backup = { # TODO: Remove when replication setup
script = ''
${pkgs.podman}/bin/podman exec swgal_db_1 sh -c 'exec mysqldump --no-tablespaces -usgr_user -psgr_pass sgr_db' > ${volumePath}/flamesites/swgalaxyproject/dbBackups/db.sql
${pkgs.podman}/bin/podman exec nnsbluegrass_db_1 sh -c 'exec mysqldump --no-tablespaces -unns_user -pnns_pass nns_db' > ${volumePath}/flamesites/nnsbluegrass/dbBackups/db.sql
'';
serviceConfig = {
Type = "oneshot";
User = "crow";
};
};
services.caddy = {
enable = true;
virtualHosts = {
"swgalaxyproject.com".extraConfig = ''
reverse_proxy http://localhost:${builtins.toString swPort}
'';
"nnsbluegrass.com".extraConfig = ''
reverse_proxy http://localhost:${builtins.toString bandPort}
'';
};
};
virtualisation.quadlet = {
containers = {
swgalaxysite.containerConfig = {
image = "wordpress";
publishPorts = [
"${builtins.toString swPort}:80"
];
# TODO: Need to actually store secrets in a safe manner here when we cutover
};
# flamebandsite.containerConfig = {
# image = "wordpress";
# publishPorts = [
# "${builtins.toString bandPort}:80"
# ];
# # TODO: Need to actually store secrets in a safe manner here when we cutover
# };
};
};
}