summaryrefslogtreecommitdiff
path: root/hosts/gnuslashprinter/klipper.nix
blob: a19261c5f3d6bdf5c7b0f1dfd54591df65d3bbb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
	# Klipper firmware
	services.klipper = {
		enable = true;
		firmwares = {
			mcu = {
				enable = true;
				# Serial port connected to the microcontroller
				serial = "/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0";
				# Klipper flash must be enabled in order to build mcu firmware
				# The resulting `klipper-flash-mcu` command will show the location of the firmware bin in the nix store
				enableKlipperFlash = true;
				# Run klipper-genconf to generate this
				configFile = ./resources/klipper/mcu/config;
			};
		};
		configFile = ./resources/klipper/printer.cfg;
		logFile = "/var/lib/klipper/klipper.log";
	};
	# Mutable config
	services.klipper.mutableConfig = true;
	#configDir = "/var/lib/moonraker/config";  # Accessible by moonraker  # TODO

	# Moonraker web-api
	services.moonraker = {
		user = "root";
		enable = true;
		address = "0.0.0.0";
		settings = {
			#authorization = {
			#	force_logins = true;
			#	cors_domains = [
			#		"*.local"
			#		"*.lan"
			#		"*://app.fluidd.xyz"
			#		"*://my.mainsail.xyz"
			#	];
			#	trusted_clients = [
			#		"10.0.0.0/8"
			#		"127.0.0.0/8"
			#		"169.254.0.0/16"
			#		"172.16.0.0/12"
			#		"192.168.0.0/16"
			#		"FE80::/10"
			#		"::1/128"
			#	];
			#};
			#file_manager.check_klipper_config_path = false;  # Disable warning when klipper config is not accessible by moonraker
			# mainsail.cfg
			#"update_manager mainsail-config" = {
			#	type = "git_repo";
			#	primary_branch = "master";
			#	path = "~/mainsail-config";
			#	origin = "https://github.com/mainsail-crew/mainsail-config.git";
			#	managed_services = "klipper";
			#};
		};
	};

	# Mainsail web-interface
	services.mainsail = {
		enable = true;
		hostName = "0.0.0.0";
		nginx.listenAddresses = [ "0.0.0.0" ];
	};
	services.nginx.clientMaxBodySize = "1000m";  # Allow large gcodes, etc.
	networking.firewall.allowedTCPPorts = [ 80 ];  # Port for mainsail via nginx

	# Webcam support in mainsail
	services.ustreamer.enable = true;
	services.mainsail.nginx.locations."/webcam/".proxyPass = "http://localhost:8080/stream";  # Default location for ustreamer stream
}