chore: add octoprint & orca slicer

This commit is contained in:
2026-01-21 15:35:19 -05:00
parent 385773ed26
commit cbcf476002
3 changed files with 88 additions and 1 deletions

View File

@@ -55,6 +55,10 @@ in
}; };
}; };
home.packages = with pkgs; [
orca-slicer
];
dconf = { dconf = {
settings = { settings = {
"org/gnome/desktop/interface" = { "org/gnome/desktop/interface" = {

View File

@@ -0,0 +1,79 @@
{ config
, pkgs
, lib
, namespace
, ...
}:
let
inherit (lib) mkIf types mkEnableOption;
inherit (lib.${namespace}) mkOpt;
settingsFormat = pkgs.formats.yaml { };
cfg = config.${namespace}.services.octoprint;
in
{
options.${namespace}.services.octoprint = {
enable = mkEnableOption "Enable OctoPrint service";
openFirewall = mkEnableOption "Open firewall";
port = mkOpt types.port 5000 "Port to listen on";
settings = lib.mkOption {
type = lib.types.submodule { freeformType = settingsFormat.type; };
default = { };
description = ''
OctoPrint configuration. Refer to the [OctoPrint example configuration](https://docs.octoprint.org/en/main/configuration/config_yaml.html)
for details on supported values.
'';
};
};
config = mkIf cfg.enable {
# Create User
users.groups.octoprint = { };
users.users.octoprint = {
isSystemUser = true;
group = "octoprint";
extraGroups = [ "dialout" ];
};
# Create Service
systemd.services.octoprint =
let
# Merge Port
finalSettings = lib.recursiveUpdate cfg.settings {
server.port = cfg.port;
};
# Create Config
configFile = settingsFormat.generate "config.yaml" finalSettings;
in
{
description = "OctoPrint 3D Printing Service";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "exec";
ExecStartPre = pkgs.writeShellScript "setup-octoprint-config" ''
if [ ! -f /var/lib/octoprint/config.yaml ]; then
${pkgs.coreutils}/bin/cp ${configFile} /var/lib/octoprint/config.yaml
fi
'';
ExecStart = "${lib.getExe pkgs.octoprint} serve -b /var/lib/octoprint";
Restart = "on-failure";
RestartSec = 3;
StateDirectory = "octoprint";
WorkingDirectory = "/var/lib/octoprint";
Environment = "HOME=/var/lib/octoprint";
User = "octoprint";
Group = "octoprint";
SupplementaryGroups = [ "dialout" ];
PrivateDevices = false;
};
};
networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; };
};
}

View File

@@ -42,9 +42,13 @@ in
}; };
services = { services = {
openssh = enabled;
avahi = enabled; avahi = enabled;
openssh = enabled;
ydotool = enabled; ydotool = enabled;
octoprint = {
enable = true;
openFirewall = true;
};
}; };
virtualisation = { virtualisation = {