From 3f509cc124cd8a2582b6b5d7cb3af3181de5c93a Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Wed, 20 Aug 2025 23:58:18 +0000 Subject: [PATCH] Add fieldseeker webserver --- host/sync/configuration.nix | 1 + modules/system/fieldseeker-sync.nix | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/host/sync/configuration.nix b/host/sync/configuration.nix index 341a554..dc45ace 100644 --- a/host/sync/configuration.nix +++ b/host/sync/configuration.nix @@ -2,5 +2,6 @@ imports = [ ./hardware-configuration.nix ]; + myModules.caddy.enable = true; myModules.fieldseeker-sync.enable = true; } diff --git a/modules/system/fieldseeker-sync.nix b/modules/system/fieldseeker-sync.nix index d97db10..7f82bf3 100644 --- a/modules/system/fieldseeker-sync.nix +++ b/modules/system/fieldseeker-sync.nix @@ -14,6 +14,9 @@ in { environment.systemPackages = [ src ]; + services.caddy.virtualHosts."deltamvcd.nidus.cloud".extraConfig = '' + reverse_proxy http://127.0.0.1:3000 + ''; services.postgresql = { enable = true; ensureDatabases = [ "fieldseeker-sync" ]; @@ -31,10 +34,12 @@ in { restartUnits = ["fieldseeker-sync.service"]; sopsFile = ../../secrets/fieldseeker-sync.env; }; - systemd.services.fieldseeker-sync = { + systemd.services.fieldseeker-sync-export = { after=["network.target" "network-online.target"]; - description="FieldSeeker sync"; + description="FieldSeeker sync periodic sync tool"; requires=["network-online.target"]; + restartIfChanged = false; + stopIfChanged = false; serviceConfig = { EnvironmentFile="/var/run/secrets/fieldseeker-sync-env"; Type = "oneshot"; @@ -47,12 +52,28 @@ in { }; wantedBy = ["multi-user.target"]; }; - systemd.timers.fieldseeker-sync = { + systemd.services.fieldseeker-sync-webserver = { + after=["network.target" "network-online.target"]; + description="FieldSeeker sync"; + requires=["network-online.target"]; + serviceConfig = { + EnvironmentFile="/var/run/secrets/fieldseeker-sync-env"; + Type = "simple"; + User = "fieldseeker-sync"; + Group = "fieldseeker-sync"; + ExecStart = "${src}/bin/webserver"; + TimeoutStopSec = "5s"; + PrivateTmp = true; + WorkingDirectory = "/tmp"; + }; + wantedBy = ["multi-user.target"]; + }; + systemd.timers.fieldseeker-sync-export = { wantedBy = ["timers.target"]; timerConfig = { OnBootSec = "15m"; OnUnitActiveSec = "15m"; - Unit = "fieldseeker-sync.service"; + Unit = "fieldseeker-sync-export.service"; }; }; users.groups.fieldseeker-sync = {};