Jump to content

3D Printing: Difference between revisions

From Official NixOS Wiki
Cktiel (talk | contribs)
No edit summary
Cktiel (talk | contribs)
No edit summary
(6 intermediate revisions by the same user not shown)
Line 24: Line 24:
   };
   };
};
};
services.mainsail.enable = true;
#services.fluidd.enable = true; 


systemd.services.klipper.serviceConfig = {
systemd.services.klipper.serviceConfig = {
Line 30: Line 33:
   ];
   ];
};
};
services.mainsail.enable = true;
#services.fluidd.enable = true; 


services.klipper = {
services.klipper = {
Line 53: Line 53:
         "192.168.0.0/16"
         "192.168.0.0/16"
         "172.16.0.0/12"
         "172.16.0.0/12"
        "100.64.0.0/10"
        "fd7a:115c:a1e0::/48"
         "fe80::/10"
         "fe80::/10"
       ];
       ];
Line 61: Line 59:
         "http://*.lan"
         "http://*.lan"
         "http://*.local"
         "http://*.local"
        "https://*.local"
        "https://*.lan"
         "https://my.mainsail.xyz"
         "https://my.mainsail.xyz"
         "http://my.mainsail.xyz"
         "http://my.mainsail.xyz"
Line 86: Line 86:
};
};
</syntaxhighlight>
</syntaxhighlight>
== Webcam ==
[https://github.com/pikvm/ustreamer Ustreamer] can be configured for access to a webcam in Mainsail or Fluidd. Below is an example configuration of a 720p webcam.
<syntaxhighlight lang="nix">
services.ustreamer = {
  enable = true;
  autoStart = true;
  device = "/dev/v4l/by-id/YOUR_DEVICE_HERE";
  extraArgs = [
    "-r 1280x720"
    "--encoder=HW"
    "--persistent"
  ];
  listenAddress = "0.0.0.0:8080";
};
</syntaxhighlight>
The stream URL for your webcam will be http://<YOUR_IP>:8080/stream. The snapshot URL will be http://<YOUR_IP>:8080/snapshot.
[[Category:Guide]]
[[Category:Web Applications]]

Revision as of 15:26, 18 September 2026

NixOS can be used as a Klipper host. This is a great alternative to a KIAUH installation.

Installation

Below is a basic configuration example that can be used to install Klipper, Moonraker and Mainsail/Fluidd:

users.users.klipper = {
  group = "klipper";
  extraGroups  = [ "dialout" ];
  isSystemUser = true;
};
users.groups.klipper = {};

systemd.tmpfiles.settings = {
  "klipper" = {
    "/srv/printer_data" = {
      d = {
        group = "klipper";
        mode = "0755";
        user = "klipper";
      }; 
    };
  };
};

services.mainsail.enable = true; 
#services.fluidd.enable = true;  

systemd.services.klipper.serviceConfig = {
  ReadWritePaths = [ 
    "/srv/printer_data"
  ];
};

services.klipper = {
  configFile = "/srv/printer_data/config/printer.cfg";
  enable = true;
  configDir = "/srv/printer_data/config";
  mutableConfig = true;
};

services.moonraker = {
  enable = true;
  user = "klipper";
  stateDir = "/srv/printer_data";
  settings = {
    authorization = {
      trusted_clients = [
        "127.0.0.1"
        "::1"
        "10.0.0.0/8"
        "192.168.0.0/16"
        "172.16.0.0/12"
        "fe80::/10"
      ];
      
      cors_domains = [
        "http://*.lan"
        "http://*.local"
        "https://*.local"
        "https://*.lan"
        "https://my.mainsail.xyz"
        "http://my.mainsail.xyz"
        "https://app.fluidd.xyz"
        "http://app.fluidd.xyz"
      ];
    };
  };
};

This configuration, similarly to KIAUH, sets up a printer_data directory at /srv/printer_data. Copy your printer.cfg into /srv/printer_data/config.

Klipper can also be configured declaratively:

services.klipper = {
  enable = true;
  mutableConfig = false;
  settings = {
    mcu = {
      baud   = 250000;
    };
  };
};

Webcam

Ustreamer can be configured for access to a webcam in Mainsail or Fluidd. Below is an example configuration of a 720p webcam.

services.ustreamer = {
  enable = true;
  autoStart = true;
  device = "/dev/v4l/by-id/YOUR_DEVICE_HERE";
  extraArgs = [
    "-r 1280x720"
    "--encoder=HW"
    "--persistent"
  ];
  listenAddress = "0.0.0.0:8080";
};

The stream URL for your webcam will be http://<YOUR_IP>:8080/stream. The snapshot URL will be http://<YOUR_IP>:8080/snapshot.