Merge pull request #231881 from lovesegfault/klipper-log

This commit is contained in:
Bernardo Meurer 2023-05-14 16:48:48 -04:00 committed by GitHub
commit d8b94f5b2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -23,6 +23,16 @@ in
description = lib.mdDoc "The Klipper package.";
};
logFile = mkOption {
type = types.nullOr types.path;
default = null;
example = "/var/lib/klipper/klipper.log";
description = lib.mdDoc ''
Path of the file Klipper should log to.
If `null`, it logs to stdout, which is not recommended by upstream.
'';
};
inputTTY = mkOption {
type = types.path;
default = "/run/klipper/tty";
@ -151,7 +161,9 @@ in
systemd.services.klipper =
let
klippyArgs = "--input-tty=${cfg.inputTTY}"
+ optionalString (cfg.apiSocket != null) " --api-server=${cfg.apiSocket}";
+ optionalString (cfg.apiSocket != null) " --api-server=${cfg.apiSocket}"
+ optionalString (cfg.logFile != null) " --logfile=${cfg.logFile}"
;
printerConfigPath =
if cfg.mutableConfig
then cfg.mutableConfigFolder + "/printer.cfg"
@ -177,7 +189,7 @@ in
'';
serviceConfig = {
ExecStart = "${cfg.package}/lib/klipper/klippy.py ${klippyArgs} ${printerConfigPath}";
ExecStart = "${cfg.package}/bin/klippy ${klippyArgs} ${printerConfigPath}";
RuntimeDirectory = "klipper";
StateDirectory = "klipper";
SupplementaryGroups = [ "dialout" ];

View File

@ -3,6 +3,7 @@
, fetchFromGitHub
, python3
, unstableGitUpdater
, makeWrapper
}:
stdenv.mkDerivation rec {
@ -19,7 +20,10 @@ stdenv.mkDerivation rec {
sourceRoot = "source/klippy";
# NB: This is needed for the postBuild step
nativeBuildInputs = [ (python3.withPackages ( p: with p; [ cffi ] )) ];
nativeBuildInputs = [
(python3.withPackages ( p: with p; [ cffi ] ))
makeWrapper
];
buildInputs = [ (python3.withPackages (p: with p; [ cffi pyserial greenlet jinja2 markupsafe numpy ])) ];
@ -49,7 +53,9 @@ stdenv.mkDerivation rec {
cp -r $src/docs $out/lib/docs
cp -r $src/config $out/lib/config
mkdir -p $out/bin
chmod 755 $out/lib/klipper/klippy.py
makeWrapper $out/lib/klipper/klippy.py $out/bin/klippy --chdir $out/lib/klipper
runHook postInstall
'';