From de106f53f2a91df6d4e61757b92e86f03f6966ac Mon Sep 17 00:00:00 2001 From: matthewcroughan Date: Sun, 19 Apr 2026 21:38:22 +0100 Subject: [PATCH] klipper: fix cross --- pkgs/servers/klipper/cross-ffi.patch | 14 ++++++++++++++ pkgs/servers/klipper/default.nix | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 pkgs/servers/klipper/cross-ffi.patch diff --git a/pkgs/servers/klipper/cross-ffi.patch b/pkgs/servers/klipper/cross-ffi.patch new file mode 100644 index 000000000000..9535d29c723f --- /dev/null +++ b/pkgs/servers/klipper/cross-ffi.patch @@ -0,0 +1,14 @@ +diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py +index c26196e..b00bd97 100644 +--- a/chelper/__init__.py ++++ b/chelper/__init__.py +@@ -318,11 +318,6 @@ def get_ffi(): + FFI_main = cffi.FFI() + for d in defs_all: + FFI_main.cdef(d) +- FFI_lib = FFI_main.dlopen(destlib) +- # Setup error logging +- pyhelper_logging_callback = FFI_main.callback("void func(const char *)", +- logging_callback) +- FFI_lib.set_python_logging_callback(pyhelper_logging_callback) + return FFI_main, FFI_lib diff --git a/pkgs/servers/klipper/default.nix b/pkgs/servers/klipper/default.nix index a0af8d52230e..2ac50f350bc8 100644 --- a/pkgs/servers/klipper/default.nix +++ b/pkgs/servers/klipper/default.nix @@ -3,6 +3,7 @@ lib, fetchFromGitHub, python3, + python3Packages, extraPythonPackages ? ps: [ ], unstableGitUpdater, makeWrapper, @@ -24,7 +25,7 @@ stdenv.mkDerivation rec { # NB: This is needed for the postBuild step nativeBuildInputs = [ - (python3.withPackages (p: with p; [ cffi ])) + python3Packages.cffi makeWrapper ]; @@ -62,6 +63,11 @@ stdenv.mkDerivation rec { --replace 'GCC_CMD = "gcc"' 'GCC_CMD = "${stdenv.cc.targetPrefix}cc"' ''; + patches = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + # https://github.com/Klipper3d/klipper/pull/7254 + ./cross-ffi.patch + ]; + pythonInterpreter = (python3.withPackages ( p: with p; [