Skip to content

Commit

Permalink
klipper: add calibrate_shaper script as a binary (#344956)
Browse files Browse the repository at this point in the history
  • Loading branch information
cab404 authored Oct 1, 2024
2 parents 9150641 + 87cc7fe commit f10fe6a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkgs/servers/klipper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, python3
, unstableGitUpdater
, makeWrapper
, writeShellScript
}:

stdenv.mkDerivation rec {
Expand Down Expand Up @@ -44,6 +45,18 @@ stdenv.mkDerivation rec {
--replace 'GCC_CMD = "gcc"' 'GCC_CMD = "${stdenv.cc.targetPrefix}cc"'
'';

pythonInterpreter =
(python3.withPackages (
p: with p; [
numpy
matplotlib
]
)).interpreter;

pythonScriptWrapper = writeShellScript pname ''
${pythonInterpreter} "@out@/lib/scripts/@script@" "$@"
'';

# NB: We don't move the main entry point into `/bin`, or even symlink it,
# because it uses relative paths to find necessary modules. We could wrap but
# this is used 99% of the time as a service, so it's not worth the effort.
Expand All @@ -56,6 +69,8 @@ stdenv.mkDerivation rec {
# under `klipper_path`
cp -r $src/docs $out/lib/docs
cp -r $src/config $out/lib/config
cp -r $src/scripts $out/lib/scripts
cp -r $src/klippy $out/lib/klippy
# Add version information. For the normal procedure see https://www.klipper3d.org/Packaging.html#versioning
# This is done like this because scripts/make_version.py is not available when sourceRoot is set to "${src.name}/klippy"
Expand All @@ -64,6 +79,12 @@ stdenv.mkDerivation rec {
mkdir -p $out/bin
chmod 755 $out/lib/klipper/klippy.py
makeWrapper $out/lib/klipper/klippy.py $out/bin/klippy --chdir $out/lib/klipper
substitute "$pythonScriptWrapper" "$out/bin/klipper-calibrate-shaper" \
--subst-var "out" \
--subst-var-by "script" "calibrate_shaper.py"
chmod 755 "$out/bin/klipper-calibrate-shaper"
runHook postInstall
'';

Expand Down

0 comments on commit f10fe6a

Please sign in to comment.