about summary refs log tree commit diff
path: root/pkgs/development/python-modules/tpm2-pytss/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/tpm2-pytss/default.nix')
-rw-r--r--pkgs/development/python-modules/tpm2-pytss/default.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/tpm2-pytss/default.nix b/pkgs/development/python-modules/tpm2-pytss/default.nix
index 484f3dc2d16e3..7b5fd56b0a109 100644
--- a/pkgs/development/python-modules/tpm2-pytss/default.nix
+++ b/pkgs/development/python-modules/tpm2-pytss/default.nix
@@ -1,4 +1,6 @@
 { lib
+, stdenv
+, substituteAll
 , buildPythonPackage
 , fetchPypi
 , pythonOlder
@@ -17,6 +19,9 @@
 , swtpm
 }:
 
+let
+  isCross = (stdenv.buildPlatform != stdenv.hostPlatform);
+in
 buildPythonPackage rec {
   pname = "tpm2-pytss";
   version = "2.2.1";
@@ -32,6 +37,18 @@ buildPythonPackage rec {
   patches = [
     # Fix hardcoded `fapi-config.json` configuration path
     ./fapi-config.patch
+  ] ++ lib.optionals isCross [
+    # pytss will regenerate files from headers of tpm2-tss.
+    # Those headers are fed through a compiler via pycparser. pycparser expects `cpp`
+    # to be in the path.
+    # This is put in the path via stdenv when not cross-compiling, but this is absent
+    # when cross-compiling is turned on.
+    # This patch changes the call to pycparser.preprocess_file to provide the name
+    # of the cross-compiling cpp
+    (substituteAll {
+      src = ./cross.patch;
+      crossPrefix = stdenv.hostPlatform.config;
+    })
   ];
 
   postPatch = ''