2022-04-27 09:35:20 +00:00
|
|
|
{ lib
|
2024-04-21 15:54:59 +00:00
|
|
|
, stdenv
|
|
|
|
, substituteAll
|
2022-04-27 09:35:20 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, pythonOlder
|
|
|
|
, asn1crypto
|
|
|
|
, cffi
|
|
|
|
, cryptography
|
2022-08-12 12:06:08 +00:00
|
|
|
, pkgconfig # see nativeBuildInputs
|
|
|
|
, pkg-config # see nativeBuildInputs
|
2022-04-27 09:35:20 +00:00
|
|
|
, pycparser
|
|
|
|
, pytestCheckHook
|
|
|
|
, python
|
2022-08-12 12:06:08 +00:00
|
|
|
, pyyaml
|
2022-04-27 09:35:20 +00:00
|
|
|
, setuptools-scm
|
2021-03-09 03:18:52 +00:00
|
|
|
, tpm2-tss
|
2023-08-04 22:07:22 +00:00
|
|
|
, tpm2-tools
|
|
|
|
, swtpm
|
2021-03-09 03:18:52 +00:00
|
|
|
}:
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
let
|
|
|
|
isCross = (stdenv.buildPlatform != stdenv.hostPlatform);
|
|
|
|
in
|
2021-03-09 03:18:52 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "tpm2-pytss";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "2.2.1";
|
2022-12-28 21:21:41 +00:00
|
|
|
format = "setuptools";
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2021-03-09 03:18:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-uPFUc0IvN39ZxyF9zRR5FlzOYt+jOTTsl2oni68unv4=";
|
2021-03-09 03:18:52 +00:00
|
|
|
};
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
patches = [
|
|
|
|
# Fix hardcoded `fapi-config.json` configuration path
|
|
|
|
./fapi-config.patch
|
2024-04-21 15:54:59 +00:00
|
|
|
] ++ 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;
|
|
|
|
})
|
2023-08-04 22:07:22 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
sed -i "s#@TPM2_TSS@#${tpm2-tss.out}#" src/tpm2_pytss/FAPI.py
|
|
|
|
'';
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
# Hardening has to be disabled
|
|
|
|
# due to pycparsing handling it poorly.
|
|
|
|
# See https://github.com/NixOS/nixpkgs/issues/252023
|
|
|
|
# for more details.
|
|
|
|
hardeningDisable = [
|
|
|
|
"fortify"
|
|
|
|
];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cffi
|
2022-12-28 21:21:41 +00:00
|
|
|
pkgconfig # this is the Python module
|
2022-08-12 12:06:08 +00:00
|
|
|
pkg-config # this is the actual pkg-config tool
|
2022-04-27 09:35:20 +00:00
|
|
|
setuptools-scm
|
|
|
|
];
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
buildInputs = [
|
|
|
|
tpm2-tss
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
cffi
|
|
|
|
asn1crypto
|
2021-03-09 03:18:52 +00:00
|
|
|
cryptography
|
2022-08-12 12:06:08 +00:00
|
|
|
pyyaml
|
2022-04-27 09:35:20 +00:00
|
|
|
];
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
doCheck = true;
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-04-27 09:35:20 +00:00
|
|
|
pytestCheckHook
|
2023-08-04 22:07:22 +00:00
|
|
|
tpm2-tools
|
|
|
|
swtpm
|
2021-03-09 03:18:52 +00:00
|
|
|
];
|
|
|
|
|
2022-12-28 21:21:41 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"tpm2_pytss"
|
|
|
|
];
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/tpm2-software/tpm2-pytss";
|
2022-12-28 21:21:41 +00:00
|
|
|
changelog = "https://github.com/tpm2-software/tpm2-pytss/blob/${version}/CHANGELOG.md";
|
2021-03-09 03:18:52 +00:00
|
|
|
description = "TPM2 TSS Python bindings for Enhanced System API (ESYS)";
|
|
|
|
license = licenses.bsd2;
|
|
|
|
maintainers = with maintainers; [ baloo ];
|
|
|
|
};
|
|
|
|
}
|