feat(octoprint): init on logistics

This commit is contained in:
arcnmx 2024-07-13 11:01:52 -07:00
parent aeb63b345b
commit 5508982563
8 changed files with 162 additions and 2 deletions

View file

@ -0,0 +1,58 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (config.services) octoprint;
name.shortServer = mkDefault "print";
upstreamName = "octoprint'access";
in {
config.services.nginx = {
upstreams'.${upstreamName}.servers = {
local = {
enable = mkDefault octoprint.enable;
addr = mkDefault "localhost";
port = mkIf octoprint.enable (mkDefault octoprint.port);
};
service = {upstream, ...}: {
enable = mkIf upstream.servers.local.enable (mkDefault false);
accessService = {
name = "octoprint";
# XXX: logistics doesn't listen on v6
getAddressFor = "getAddress4For";
};
};
};
virtualHosts = let
copyFromVhost = mkDefault "octoprint";
locations = {
"/" = {
proxy.enable = true;
};
"/sockjs/" = {
proxy = {
enable = true;
websocket.enable = true;
};
};
};
in {
octoprint = {
inherit name locations;
proxy.upstream = mkDefault upstreamName;
vouch.enable = mkDefault true;
};
octoprint'local = {
inherit name locations;
ssl.cert = {
inherit copyFromVhost;
};
proxy = {
inherit copyFromVhost;
};
local.enable = mkDefault true;
};
};
};
}