diff --git a/bert/services/http/svsindustries.org.nix b/bert/services/http/svsindustries.org.nix index d9ad3c9..c15966a 100644 --- a/bert/services/http/svsindustries.org.nix +++ b/bert/services/http/svsindustries.org.nix @@ -1,20 +1,63 @@ +{ config, pkgs, ... }: +let + svsServicesSrc = pkgs.fetchgit { + url = "https://git.chandlerswift.com/chandlerswift/svs-services-server"; + rev = "ac0b8d427395e8b9ba51857a80256ceaf550b0a6"; + sha256 = "sha256-wxGpc1YarF55buP1CMrZwEVBFLwLtkc8swdciNjijvw="; + }; + svsServicesServer = pkgs.buildGoModule { + pname = "svs-services-server"; + version = "2025-12-28"; + src = svsServicesSrc; + vendorHash = "sha256-MmVwi5VZlw63LUG52i7wrb8OYHJDmHb9bXvsGilU5nY="; + subPackages = [ "." ]; + }; + + svsLanding = pkgs.runCommand "svsindustries-landing" { } '' + mkdir -p "$out" + cp ${svsServicesSrc}/landing-page.html "$out/index.html" + ''; +in { + systemd.services.svs-services-server = { + enable = true; + description = "SVS Industries services server"; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${svsServicesServer}/bin/svs-services-server -database %S/svs-services-server/svs-services.db -completion-provider openrouter"; + Restart = "on-failure"; + DynamicUser = true; + StateDirectory = "svs-services-server"; + WorkingDirectory = "%S/svs-services-server"; + EnvironmentFile = "/root/svs-services-server-env"; + }; + }; + services.caddy.virtualHosts."svsindustries.org" = { - # serverAliases = ["*.svsindustries.org"]; + serverAliases = [ "www.svsindustries.org" ]; extraConfig = '' encode zstd gzip + root * ${svsLanding} file_server - root * /srv/www/svsindustries.org handle_errors { respond "{err.status_code} {err.status_text}" } ''; }; - systemd.tmpfiles.settings."10-svsindustries-org" = { - "/srv/www/svsindustries.org" = { - d = {}; - }; + + services.caddy.virtualHosts."*.svsindustries.org" = { + extraConfig = '' + tls /srv/svsindustries.org-ssl-bundle/domain.cert.pem /srv/svsindustries.org-ssl-bundle/private.key.pem + encode zstd gzip + reverse_proxy localhost:64434 + + handle_errors { + respond "{err.status_code} {err.status_text}" + } + ''; }; }