Skip to content

Commit

Permalink
Replace octoprint with moonraker and mainsail
Browse files Browse the repository at this point in the history
  • Loading branch information
gradientvera committed Oct 23, 2023
1 parent 6a55a6e commit b66a810
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 46 deletions.
6 changes: 4 additions & 2 deletions hosts/briah/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
./duckdns.nix
#./grafana.nix
./programs.nix
./octoprint.nix
./mainsail.nix
#./octoprint.nix
./moonraker.nix
./ustreamer.nix
#./promtail.nix
./syncthing.nix
Expand All @@ -16,8 +18,8 @@
#./containers.nix
./filesystems.nix
# ./ss14-watchdog.nix
./kiosk-session.nix
./secrets/default.nix
./octoprint-session.nix
];

boot.loader.raspberryPi.firmwareConfig = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ in {
services.cage = {
enable = true;
user = "vera";
program = "${pkgs.unstable.chromium}/bin/chromium --noerrdialogs --disable-infobars --incognito --kiosk http://127.0.0.1:${toString ports.octoprint}";
program = "${pkgs.unstable.chromium}/bin/chromium --noerrdialogs --disable-infobars --incognito --kiosk http://127.0.0.1:${toString ports.mainsail}";
extraArguments = [ "-d" ];
};

Expand All @@ -15,7 +15,7 @@ in {
cma = 256;
};

systemd.services."cage-tty1".after = [ "octoprint.service" ];
systemd.services."cage-tty1".after = [ "nginx.service" "moonraker.service" ];

systemd.services."serial-getty@ttyS0".enable = false;
systemd.services."serial-getty@hvc0".enable = false;
Expand Down
2 changes: 1 addition & 1 deletion hosts/briah/klipper.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

[exclude_object]
[virtual_sdcard]
path: ~/gcode_files
path: /var/lib/moonraker/gcodes

[pause_resume]

Expand Down
5 changes: 3 additions & 2 deletions hosts/briah/klipper.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{ ... }:
{ config, ... }:
{

services.klipper = {
enable = true;
user = config.services.moonraker.user;
group = config.services.moonraker.group;
configFile = ./klipper.cfg;
mutableConfig = true;
octoprintIntegration = true;
logFile = "/var/lib/klipper/klipper.log";
};

Expand Down
27 changes: 27 additions & 0 deletions hosts/briah/mainsail.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ ... }:
let
ports = import ./misc/service-ports.nix;
addresses = import ../../misc/wireguard-addresses.nix;
in {

services.mainsail = {
enable = true;
nginx.listen = [
{
addr = "127.0.0.1";
port = ports.mainsail;
}
{
addr = addresses.gradientnet.briah;
port = ports.mainsail;
}
];
};

# Increase max upload size for uploading gcode files from PrusaSlicer
services.nginx.clientMaxBodySize = "1000m";

networking.firewall.interfaces.gradientnet.allowedTCPPorts = [ ports.mainsail ];
networking.firewall.interfaces.gradientnet.allowedUDPPorts = [ ports.mainsail ];

}
4 changes: 3 additions & 1 deletion hosts/briah/misc/service-ports.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
promtail = 9005;
syncthing-transfers = 22000;

octoprint = 5000;
mainsail = 5000;
ustreamer = 5050;

moonraker = 7125;

}
53 changes: 53 additions & 0 deletions hosts/briah/moonraker.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{ config, ... }:
let
ports = import ./misc/service-ports.nix;
addresses = import ../../misc/wireguard-addresses.nix;
ustreamer-address = "http://${addresses.gradientnet.briah}:${toString ports.ustreamer}";
in {

services.moonraker = {
enable = true;
allowSystemControl = true;
address = "0.0.0.0";
port = ports.moonraker;
settings = {

octoprint_compat = { };

history = { };

authorization = {
cors_domains = [
"*://${config.networking.hostName}:*"
];
trusted_clients = [
"127.0.0.1"
"${addresses.gradientnet.gradientnet}/24"
];
};

# Enable ustreamer camera support.
"webcam c920" = {
enabled = "True";
service = "uv4l-mjpeg";
stream_url = "${ustreamer-address}/stream";
snapshot_url = "${ustreamer-address}/snapshot";
aspect_ratio = "16:9";
target_fps = 30;
};

# Enable Telegram notification support.
"notifier telegram" = {
url = "tgram://{secrets.telegram.token}/{secrets.telegram.chat}";
events = "*";
body = "Your printer status has changed to {event_name}";
attach = "${ustreamer-address}/snapshot";
};

};
};

networking.firewall.interfaces.gradientnet.allowedTCPPorts = [ ports.moonraker ];
networking.firewall.interfaces.gradientnet.allowedUDPPorts = [ ports.moonraker ];

}
35 changes: 0 additions & 35 deletions hosts/briah/octoprint.nix

This file was deleted.

7 changes: 7 additions & 0 deletions hosts/briah/secrets/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
restartUnits = [ "syncthing.service" ];
};

moonraker = {
owner = config.services.moonraker.user;
group = config.services.moonraker.group;
path = "${config.services.moonraker.stateDir}/moonraker.secrets";
restartUnits = [ "moonraker.service" ];
};

};
};

Expand Down
7 changes: 4 additions & 3 deletions hosts/briah/secrets/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ wireguard-private-key: ENC[AES256_GCM,data:wowzTQEOBM4chO8cnf7168VzfIP2kB46bHZwR
pong-api-token: ENC[AES256_GCM,data:XTnnBPayTtpdwqefyvj0WZ1/TtjGmR16pyveoDZIQI4=,iv:L9gEQpRp+ANH8klmeBJSkaPaBcRsrTdhqd8ZCAwl++M=,tag:US5FYzBbkcNg0RcoIYu6ZA==,type:str]
duckdns: ENC[AES256_GCM,data:pVrAfa3UW6mdSUkUMZr5aYKdX7vbQ+GOiAONL+mlIv18GR1EsGuYTfTwq1MawV25G5LkyVZxmQb9z1xAi+rSTeKWLCG6o/Ktls42ngSl1xaAD3CvBAfdvZ5UXfQ9arj+NH9WrefLDn9gy5618Ens0SAUUbP1fGpd1ZeCdJ8tU/7cKB0uL+PZZ5NWfnxNQx6VgC2hXISrPg==,iv:9Qc3sNaYw6+bAKoylOwjsaLf+i8eTgsab/Db8fUYBFI=,tag:CrhGdMXSgwGpxrLuv10sKA==,type:str]
stream-htpasswd: ENC[AES256_GCM,data:rINcLWiMdsr2xqQ01cIsUoxJIGciP/PmrDGdfSbCinTwaIg7Alr5UkeSbPWD,iv:SlYHi0Gm12d8w15SaE20COkL9hP8mjdqCOjA1evC7tQ=,tag:1rvD06B5gYQHJ9+7S08V1w==,type:str]
moonraker: ENC[AES256_GCM,data:UxUHzmKbKzauTWxkySFRWvTRD8+N1ZH9/48Bprfuq5wZ0elZ2iq2hmVsB85loW4V6r5wOk0AExi9LCyW/5jrI3XeRsBwRyIKzCUUEts9x9A=,iv:/Yoq34ZAFI1e62KzS/tGtYcCKUnbPXEgsYemYE1W8oc=,tag:wWU2x3laB7oiCt+ds7JKcw==,type:str]
sops:
kms: []
gcp_kms: []
Expand All @@ -26,8 +27,8 @@ sops:
QzI5MjlQUkE3Sk9ORkRXbmtEYjVTZGMKURNm0IvTA1Ptm+Nqpo2YPmotMTIacFRW
VC08uQPI+6N2brWZpEFOuctZ0rGcn1XcpgD69WuUrseu4rjVqioesA==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2023-07-24T08:53:57Z"
mac: ENC[AES256_GCM,data:YLuIq0pu+bogx0DE/F0KGoOuLLRq7aLg9te+Y7oN95dJQFlXxbf80jQN5UVWWbJ6C94ByK6u2eCFlx1K1VGjgVc/tBD0w5NJETGHqIB3dy7qQ8bjvEcxWckkA8trTiBYN0rACvRLLxnub0IwWUq5dUSpMlj6q+Moiw24L4lHCsQ=,iv:zv1bBIGPjULQ9EY91pu54ZUCfkAV27fSlZbTITpBWYg=,tag:ZJ3ddyDLAiuJls6COK77SQ==,type:str]
lastmodified: "2023-10-23T15:26:33Z"
mac: ENC[AES256_GCM,data:3qeg+Ols1oYXDoeYArnxO8NG5kWGHRw4I/xHjaQzYproWMJMl+Rjg2z1hR4umJDE+6gqvP5wPEl/WCdZMR0AgUpwa83I/9jonQ44xiycNgloNuOeDwqrFq/wP4iweZXtqwsillW9k11FRrANk5UbVCSFMmSONlUGXvJSZV7riY4=,iv:5WWuR7Kmi6SMFl79kwLSYNnBFeBYKV2GXQbZ+aMGPFI=,tag:Zmu88Xw5RTLChYl2fZfu/A==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.7.3
version: 3.8.1

0 comments on commit b66a810

Please sign in to comment.