63 lines
1.9 KiB
Nix
63 lines
1.9 KiB
Nix
{ 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 = [ "www.svsindustries.org" ];
|
|
extraConfig = ''
|
|
encode zstd gzip
|
|
root * ${svsLanding}
|
|
file_server
|
|
|
|
handle_errors {
|
|
respond "{err.status_code} {err.status_text}"
|
|
}
|
|
'';
|
|
};
|
|
|
|
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}"
|
|
}
|
|
'';
|
|
};
|
|
}
|