From 5015c369b4dd28e2fc71f2b5e92759cd5f111665 Mon Sep 17 00:00:00 2001 From: TheWanderingCrow Date: Sun, 22 Mar 2026 00:17:33 -0400 Subject: [PATCH] get the framework for the wordpress sites into a file --- hosts/common/optional/mysql.nix | 6 +++ modules/quadlets/flamesites/default.nix | 71 +++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 hosts/common/optional/mysql.nix create mode 100644 modules/quadlets/flamesites/default.nix diff --git a/hosts/common/optional/mysql.nix b/hosts/common/optional/mysql.nix new file mode 100644 index 0000000..867072e --- /dev/null +++ b/hosts/common/optional/mysql.nix @@ -0,0 +1,6 @@ +{ + services.mysql = { + enable = true; + package = pkgs.mariadb_118; + }; +} diff --git a/modules/quadlets/flamesites/default.nix b/modules/quadlets/flamesites/default.nix new file mode 100644 index 0000000..f553062 --- /dev/null +++ b/modules/quadlets/flamesites/default.nix @@ -0,0 +1,71 @@ +{ + 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 + }; + }; + }; +}