From 0c8307882586e3072be83d88302b4363dffef755 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Sun, 18 Jul 2021 21:34:45 -0700 Subject: [PATCH] nixos/klipper: Allow configuring --input-tty and --api-server This also makes it easy for other modules to get the correct path to the virtual printer. --- nixos/modules/services/misc/klipper.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/misc/klipper.nix b/nixos/modules/services/misc/klipper.nix index 41f77da35480..4930648ba8e3 100644 --- a/nixos/modules/services/misc/klipper.nix +++ b/nixos/modules/services/misc/klipper.nix @@ -16,6 +16,19 @@ in description = "The Klipper package."; }; + inputTTY = mkOption { + type = types.path; + default = "/run/klipper/tty"; + description = "Path of the virtual printer symlink to create."; + }; + + apiSocket = mkOption { + type = types.nullOr types.path; + default = null; + example = "/run/klipper/api"; + description = "Path of the API socket to create."; + }; + octoprintIntegration = mkOption { type = types.bool; default = false; @@ -73,13 +86,16 @@ in group = config.services.octoprint.group; }; - systemd.services.klipper = { + systemd.services.klipper = let + klippyArgs = "--input-tty=${cfg.inputTTY}" + + optionalString (cfg.apiSocket != null) " --api-server=${cfg.apiSocket}"; + in { description = "Klipper 3D Printer Firmware"; wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; serviceConfig = { - ExecStart = "${cfg.package}/lib/klipper/klippy.py --input-tty=/run/klipper/tty /etc/klipper.cfg"; + ExecStart = "${cfg.package}/lib/klipper/klippy.py ${klippyArgs} /etc/klipper.cfg"; RuntimeDirectory = "klipper"; SupplementaryGroups = [ "dialout" ]; WorkingDirectory = "${cfg.package}/lib";