mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
feat(fluidd): take over print
This commit is contained in:
parent
6c3727a246
commit
1c8a8f7a9e
6 changed files with 82 additions and 21 deletions
40
modules/system/exports/fluidd.nix
Normal file
40
modules/system/exports/fluidd.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
gensokyo-zone,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (gensokyo-zone.lib) mkAlmostOptionDefault;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
in {
|
||||||
|
config.exports.services.fluidd = {config, ...}: {
|
||||||
|
displayName = mkAlmostOptionDefault "Fluidd";
|
||||||
|
id = mkAlmostOptionDefault "print";
|
||||||
|
nixos = {
|
||||||
|
serviceAttr = "fluidd";
|
||||||
|
assertions = let
|
||||||
|
mkAssertion = f: nixosConfig: let
|
||||||
|
cfg = nixosConfig.services.nginx;
|
||||||
|
in
|
||||||
|
f nixosConfig cfg;
|
||||||
|
in
|
||||||
|
mkIf config.enable [
|
||||||
|
(mkAssertion (nixosConfig: cfg: {
|
||||||
|
assertion = config.ports.default.port == 80;
|
||||||
|
message = "port mismatch";
|
||||||
|
}))
|
||||||
|
];
|
||||||
|
};
|
||||||
|
defaults.port.listen = mkAlmostOptionDefault "lan";
|
||||||
|
ports = {
|
||||||
|
default = {
|
||||||
|
port = mkAlmostOptionDefault 80;
|
||||||
|
protocol = "http";
|
||||||
|
status = {
|
||||||
|
enable = mkAlmostOptionDefault true;
|
||||||
|
gatus.client.network = mkAlmostOptionDefault "ip4";
|
||||||
|
};
|
||||||
|
prometheus.exporter.enable = mkAlmostOptionDefault true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -4,33 +4,27 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkDefault;
|
inherit (lib.modules) mkIf mkDefault;
|
||||||
inherit (config.services) octoprint;
|
inherit (config.services) nginx fluidd;
|
||||||
name.shortServer = mkDefault "print";
|
name.shortServer = mkDefault "print";
|
||||||
upstreamName = "octoprint'access";
|
upstreamName = "fluidd'access";
|
||||||
in {
|
in {
|
||||||
config.services.nginx = {
|
config.services.nginx = {
|
||||||
upstreams'.${upstreamName}.servers = {
|
upstreams'.${upstreamName}.servers = {
|
||||||
local = {
|
|
||||||
enable = mkDefault octoprint.enable;
|
|
||||||
addr = mkDefault "localhost";
|
|
||||||
port = mkIf octoprint.enable (mkDefault octoprint.port);
|
|
||||||
};
|
|
||||||
service = {upstream, ...}: {
|
service = {upstream, ...}: {
|
||||||
enable = mkIf upstream.servers.local.enable (mkDefault false);
|
enable = true;
|
||||||
accessService = {
|
accessService = {
|
||||||
name = "octoprint";
|
name = "nginx";
|
||||||
|
system = "logistics";
|
||||||
|
port = "http";
|
||||||
# XXX: logistics doesn't listen on v6
|
# XXX: logistics doesn't listen on v6
|
||||||
getAddressFor = "getAddress4For";
|
getAddressFor = "getAddress4For";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
virtualHosts = let
|
virtualHosts = let
|
||||||
copyFromVhost = mkDefault "octoprint";
|
copyFromVhost = mkDefault "fluidd";
|
||||||
locations = {
|
locations = {
|
||||||
"/" = {
|
"/" = {
|
||||||
proxy.enable = true;
|
|
||||||
};
|
|
||||||
"/sockjs/" = {
|
|
||||||
proxy = {
|
proxy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
websocket.enable = true;
|
websocket.enable = true;
|
||||||
|
|
@ -38,12 +32,15 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
octoprint = {
|
fluidd = {
|
||||||
inherit name locations;
|
inherit name locations;
|
||||||
proxy.upstream = mkDefault upstreamName;
|
proxy = {
|
||||||
|
upstream = mkDefault upstreamName;
|
||||||
|
host = nginx.virtualHosts.fluidd'local.serverName;
|
||||||
|
};
|
||||||
vouch.enable = mkDefault true;
|
vouch.enable = mkDefault true;
|
||||||
};
|
};
|
||||||
octoprint'local = {
|
fluidd'local = {
|
||||||
inherit name locations;
|
inherit name locations;
|
||||||
ssl.cert = {
|
ssl.cert = {
|
||||||
inherit copyFromVhost;
|
inherit copyFromVhost;
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,13 @@ in {
|
||||||
services = {
|
services = {
|
||||||
fluidd = {
|
fluidd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
hostName = "print.local.gensokyo.zone";
|
||||||
nginx.locations."/webcam".proxyPass = let
|
nginx.locations."/webcam".proxyPass = let
|
||||||
inherit (motion.cameras) printercam;
|
inherit (motion.cameras) printercam;
|
||||||
inherit (printercam.settings) camera_id;
|
inherit (printercam.settings) camera_id;
|
||||||
in "https://kitchen.local.${domain}/${toString camera_id}/stream";
|
in "https://kitchen.local.${domain}/${toString camera_id}/stream";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.firewall.interfaces.lan.allowedTCPPorts = [80];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
_: {
|
{ config, gensokyo-zone, ... }: let
|
||||||
|
inherit (config.services) motion;
|
||||||
|
inherit (gensokyo-zone.lib) domain;
|
||||||
|
in {
|
||||||
services = {
|
services = {
|
||||||
moonraker = {
|
moonraker = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -8,6 +11,23 @@ _: {
|
||||||
settings = {
|
settings = {
|
||||||
octoprint_compat = { };
|
octoprint_compat = { };
|
||||||
history = { };
|
history = { };
|
||||||
|
"webcam printer" = {
|
||||||
|
location = "printer";
|
||||||
|
enabled = true;
|
||||||
|
service = "mjpegstreamer";
|
||||||
|
icon = "mdiPrinter3d";
|
||||||
|
target_fps = 5;
|
||||||
|
target_fps_idle = 1;
|
||||||
|
stream_url = let
|
||||||
|
inherit (motion.cameras) printercam;
|
||||||
|
inherit (printercam.settings) camera_id;
|
||||||
|
in "https://kitchen.local.${domain}/${toString camera_id}/stream";
|
||||||
|
snapshot_url = let
|
||||||
|
inherit (motion.cameras) printercam;
|
||||||
|
inherit (printercam.settings) camera_id;
|
||||||
|
in "https://kitchen.local.${domain}/${toString camera_id}/current";
|
||||||
|
aspect_ratio = "16:9";
|
||||||
|
};
|
||||||
authorization = {
|
authorization = {
|
||||||
force_logins = true;
|
force_logins = true;
|
||||||
cors_domains = [
|
cors_domains = [
|
||||||
|
|
|
||||||
|
|
@ -269,10 +269,10 @@ in {
|
||||||
};
|
};
|
||||||
print = {
|
print = {
|
||||||
inherit (nginx) group;
|
inherit (nginx) group;
|
||||||
domain = virtualHosts.octoprint.serverName;
|
domain = virtualHosts.fluidd.serverName;
|
||||||
extraDomainNames = mkMerge [
|
extraDomainNames = mkMerge [
|
||||||
virtualHosts.octoprint.otherServerNames
|
virtualHosts.fluidd.otherServerNames
|
||||||
virtualHosts.octoprint'local.allServerNames
|
virtualHosts.fluidd'local.allServerNames
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
webrx = {
|
webrx = {
|
||||||
|
|
@ -405,7 +405,7 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
kitchencam.ssl.cert.enable = true;
|
kitchencam.ssl.cert.enable = true;
|
||||||
octoprint.ssl.cert.enable = true;
|
fluidd.ssl.cert.enable = true;
|
||||||
openwebrx.ssl.cert.enable = true;
|
openwebrx.ssl.cert.enable = true;
|
||||||
deluge.ssl.cert.enable = true;
|
deluge.ssl.cert.enable = true;
|
||||||
invidious = {
|
invidious = {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ _: {
|
||||||
octoprint.enable = true;
|
octoprint.enable = true;
|
||||||
nginx.enable = true;
|
nginx.enable = true;
|
||||||
moonraker.enable = true;
|
moonraker.enable = true;
|
||||||
|
fluidd.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
network.networks = {
|
network.networks = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue