2023-09-03 00:12:21 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
2024-08-03 17:32:02 +00:00
|
|
|
}: let
|
2023-09-03 00:12:21 +00:00
|
|
|
cfg = config.aa.services.octoprint;
|
|
|
|
in {
|
2024-08-03 17:32:02 +00:00
|
|
|
options.aa.services.octoprint = with lib; {
|
2023-09-03 00:12:21 +00:00
|
|
|
enable = mkEnableOption "octoprint";
|
|
|
|
acmeCertName = mkOption {
|
2024-08-03 17:32:02 +00:00
|
|
|
type = types.str;
|
2023-09-03 00:12:21 +00:00
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
If set to a non-empty string, foces SSL with the supplied acme
|
|
|
|
certificate.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-03 17:32:02 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2023-09-03 00:12:21 +00:00
|
|
|
services.octoprint.enable = true;
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
virtualHosts."octoprint.kilonull.com" =
|
|
|
|
{
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:${toString config.services.octoprint.port}";
|
|
|
|
proxyWebsockets = true;
|
2023-10-08 15:21:15 +00:00
|
|
|
extraConfig = ''
|
2024-03-12 03:23:12 +00:00
|
|
|
client_max_body_size 512m;
|
2023-10-08 15:21:15 +00:00
|
|
|
'';
|
2023-09-03 00:12:21 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
// lib.optionalAttrs (cfg.acmeCertName != "") {
|
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = cfg.acmeCertName;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [80 443];
|
|
|
|
};
|
|
|
|
}
|