From 9384d60317446282274f2a28ea2eb566e30ff169 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Wed, 14 Jan 2026 12:56:06 +0200 Subject: [PATCH] python3.pkgs.setuptools-rust: adjust setupHook inclusion condition Commit e65630386777c3f21977611f7b802aeae30b6f2c (PR #467817) made `setuptools-rust` work automatically in cross compilation scenarios by replacing `setuptoolsRustBuildHook` with `setuptools-rust.setupHook`. However it broke builds such as: ```sh nix build -Lf. pkgsCross.armv7l-hf-multiplatform.buildPackages.python3.pkgs.cryptography ``` As reported here: https://github.com/NixOS/nixpkgs/pull/467817#issuecomment-3731773060 This adjustment fixes the above build, while also maintaining the following working: ```sh nix build -Lf. pkgsCross.armv7l-hf-multiplatform.python3.pkgs.libcst ``` --- .../python-modules/setuptools-rust/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/setuptools-rust/default.nix b/pkgs/development/python-modules/setuptools-rust/default.nix index 8f340085ca07d..48efa6f79ba89 100644 --- a/pkgs/development/python-modules/setuptools-rust/default.nix +++ b/pkgs/development/python-modules/setuptools-rust/default.nix @@ -43,11 +43,16 @@ buildPythonPackage rec { # integrate the setup hook to set up the build environment for cross compilation # this hook is automatically propagated to consumers using setuptools-rust as build-system # - # Only include the setup hook if python.pythonOnTargetForTarget is not empty. + # No need for the setup hook when python.pythonOnTargetForTarget is empty, + # or when the host & target platforms are the same. + # # python.pythonOnTargetForTarget is not always available, for example in # pkgsLLVM.python3.pythonOnTargetForTarget. cross build with pkgsLLVM should not be affected. setupHook = - if python.pythonOnTargetForTarget == { } then + if + python.pythonOnTargetForTarget == { } + || (lib.systems.equals stdenv.hostPlatform stdenv.targetPlatform) + then null else replaceVars ./setuptools-rust-hook.sh {