Jump to content

3D Printing

From Official NixOS Wiki

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";
      }; 
    };
  };
};

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

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

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"
        "100.64.0.0/10"
        "fd7a:115c:a1e0::/48"
        "fe80::/10"
      ];
      
      cors_domains = [
        "http://*.lan"
        "http://*.local"
        "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;
    };
  };
};