11{
22 autoconf-archive ,
33 autoreconfHook ,
4+ buildEnv ,
45 clangStdenv ,
56 cmocka ,
7+ dbus ,
8+ expect ,
69 fetchFromGitHub ,
710 glibc ,
11+ gnutls ,
12+ iproute2 ,
813 lib ,
914 libyaml ,
1015 makeWrapper ,
1116 opensc ,
17+ openssh ,
1218 openssl ,
19+ nss ,
20+ p11-kit ,
1321 patchelf ,
1422 pkg-config ,
1523 python3 ,
1624 stdenv ,
1725 sqlite ,
26+ swtpm ,
1827 tpm2-abrmd ,
28+ tpm2-openssl ,
1929 tpm2-pkcs11 , # for passthru abrmd tests
2030 tpm2-tools ,
2131 tpm2-tss ,
32+ which ,
33+ xxd ,
2234 abrmdSupport ? false ,
2335 fapiSupport ? true ,
2436 enableFuzzing ? false ,
@@ -38,25 +50,37 @@ chosenStdenv.mkDerivation (finalAttrs: {
3850 hash = "sha256-W74ckrpK7ypny1L3Gn7nNbOVh8zbHavIk/TX3b8XbI8=" ;
3951 } ;
4052
41- # The preConfigure phase doesn't seem to be working here
42- # ./bootstrap MUST be executed as the first step, before all
43- # of the autoreconfHook stuff
53+ # Disable Java‐based tests because of missing dependencies
54+ patches = [ ./disable-java-integration.patch ] ;
55+
4456 postPatch = ''
45- echo "$ version" > VERSION
57+ echo ${ lib . escapeShellArg finalAttrs . version } > VERSION
4658
4759 # Don't run git in the bootstrap
4860 substituteInPlace bootstrap --replace-warn "git" "# git"
4961
50- # Don't run tests with dbus
51- substituteInPlace Makefile.am --replace-fail "dbus-run-session" "env"
62+ # Provide configuration file for D-Bus
63+ substituteInPlace Makefile.am --replace-fail \
64+ "dbus-run-session" \
65+ "dbus-run-session --config-file=${ dbus } /share/dbus-1/session.conf"
66+
67+ # Disable failing tests
68+ sed -E -i '/\<test\/integration\/(pkcs-crypt\.int|pkcs11-tool\.sh)\>/d' \
69+ Makefile-integration.am
5270
53- patchShebangs test
71+ patchShebangs test tools
5472
73+ # The preConfigure phase doesn't seem to be working here
74+ # ./bootstrap MUST be executed as the first step, before all
75+ # of the autoreconfHook stuff
5576 ./bootstrap
5677 '' ;
5778
5879 configureFlags =
59- lib . singleton ( lib . enableFeature finalAttrs . doCheck "unit" )
80+ [
81+ ( lib . enableFeature finalAttrs . doCheck "unit" )
82+ ( lib . enableFeature finalAttrs . doCheck "integration" )
83+ ]
6084 ++ lib . optionals enableFuzzing [
6185 "--enable-fuzzing"
6286 "--disable-hardening"
@@ -72,15 +96,20 @@ chosenStdenv.mkDerivation (finalAttrs: {
7296 patchelf
7397 pkg-config
7498 ( python3 . withPackages (
75- ps : with ps ; [
99+ ps :
100+ with ps ;
101+ [
76102 packaging
77103 pyyaml
104+ python-pkcs11
78105 cryptography
79106 pyasn1-modules
80107 tpm2-pytss
81108 ]
109+ ++ cryptography . optional-dependencies . ssh
82110 ) )
83111 ] ;
112+
84113 buildInputs = [
85114 libyaml
86115 opensc
@@ -89,8 +118,28 @@ chosenStdenv.mkDerivation (finalAttrs: {
89118 tpm2-tools
90119 tpm2-tss
91120 ] ;
121+
122+ nativeCheckInputs = [
123+ dbus
124+ expect
125+ gnutls
126+ iproute2
127+ nss . tools
128+ opensc
129+ openssh
130+ openssl
131+ p11-kit
132+ sqlite
133+ swtpm
134+ tpm2-abrmd
135+ tpm2-tools
136+ which
137+ xxd
138+ ] ;
139+
92140 checkInputs = [
93141 cmocka
142+ tpm2-abrmd
94143 ] ;
95144
96145 enableParallelBuilding = true ;
@@ -106,19 +155,51 @@ chosenStdenv.mkDerivation (finalAttrs: {
106155 dontStrip = true ;
107156 dontPatchELF = true ;
108157
158+ preCheck =
159+ let
160+ openssl-modules = buildEnv {
161+ name = "openssl-modules" ;
162+ pathsToLink = [ "/lib/ossl-modules" ] ;
163+ paths = map lib . getLib [
164+ openssl
165+ tpm2-openssl
166+ ] ;
167+ } ;
168+ in
169+ ''
170+ # Enable tests to load TCTI modules
171+ export LD_LIBRARY_PATH+=":${
172+ lib . makeLibraryPath [
173+ swtpm
174+ tpm2-tools
175+ tpm2-abrmd
176+ ]
177+ } "
178+
179+ # Enable tests to load TPM2 OpenSSL module
180+ export OPENSSL_MODULES="${ openssl-modules } /lib/ossl-modules"
181+ '' ;
182+
183+ postInstall = ''
184+ mkdir -p $bin/bin/ $bin/share/tpm2_pkcs11/
185+ mv ./tools/* $bin/share/tpm2_pkcs11/
186+ makeWrapper $bin/share/tpm2_pkcs11/tpm2_ptool.py $bin/bin/tpm2_ptool \
187+ --prefix PATH : ${ lib . makeBinPath [ tpm2-tools ] }
188+ '' ;
189+
109190 # To be able to use the userspace resource manager, the RUNPATH must
110191 # explicitly include the tpm2-abrmd shared libraries.
111192 preFixup =
112193 let
113194 rpath = lib . makeLibraryPath (
114- ( lib . optional abrmdSupport tpm2-abrmd )
115- ++ [
195+ [
116196 glibc
117197 libyaml
118198 openssl
119199 sqlite
120200 tpm2-tss
121201 ]
202+ ++ ( lib . optional abrmdSupport tpm2-abrmd )
122203 ) ;
123204 in
124205 ''
@@ -129,13 +210,6 @@ chosenStdenv.mkDerivation (finalAttrs: {
129210 $out/lib/libtpm2_pkcs11.so.0.0.0
130211 '' ;
131212
132- postInstall = ''
133- mkdir -p $bin/bin/ $bin/share/tpm2_pkcs11/
134- mv ./tools/* $bin/share/tpm2_pkcs11/
135- makeWrapper $bin/share/tpm2_pkcs11/tpm2_ptool.py $bin/bin/tpm2_ptool \
136- --prefix PATH : ${ lib . makeBinPath [ tpm2-tools ] }
137- '' ;
138-
139213 passthru = {
140214 tests . tpm2-pkcs11-abrmd = tpm2-pkcs11 . override {
141215 abrmdSupport = true ;
0 commit comments