2024-05-15 15:35:15 +00:00
|
|
|
{ stdenv, lib, fetchFromGitHub
|
2020-06-18 07:06:33 +00:00
|
|
|
, autoreconfHook, autoconf-archive, pkg-config, doxygen, perl
|
|
|
|
, openssl, json_c, curl, libgcrypt
|
2021-04-05 15:23:46 +00:00
|
|
|
, cmocka, uthash, ibm-sw-tpm2, iproute2, procps, which
|
2023-07-15 17:15:38 +00:00
|
|
|
, shadow, libuuid
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
2021-09-26 12:46:18 +00:00
|
|
|
let
|
|
|
|
# Avoid a circular dependency on Linux systems (systemd depends on tpm2-tss,
|
|
|
|
# tpm2-tss tests depend on procps, procps depends on systemd by default). This
|
|
|
|
# needs to be conditional based on isLinux because procps for other systems
|
|
|
|
# might not support the withSystemd option.
|
|
|
|
procpsWithoutSystemd = procps.override { withSystemd = false; };
|
|
|
|
procps_pkg = if stdenv.isLinux then procpsWithoutSystemd else procps;
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "tpm2-tss";
|
2024-06-05 15:53:02 +00:00
|
|
|
version = "4.1.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "tpm2-software";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2024-06-05 15:53:02 +00:00
|
|
|
hash = "sha256-paqTQ7DQI0Nd8q0qUPRa2UZ/oE5nrVEq5KUiG8hRXuQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
outputs = [ "out" "man" "dev" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
2020-06-18 07:06:33 +00:00
|
|
|
autoreconfHook autoconf-archive pkg-config doxygen perl
|
2022-04-27 09:35:20 +00:00
|
|
|
shadow
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2021-10-06 13:57:05 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs = [
|
|
|
|
openssl json_c curl libgcrypt uthash libuuid
|
|
|
|
]
|
|
|
|
# cmocka is checked in the configure script
|
2021-10-06 13:57:05 +00:00
|
|
|
# when unit and/or integration testing is enabled
|
2023-10-09 19:29:22 +00:00
|
|
|
# cmocka doesn't build with pkgsStatic, and we don't need it anyway
|
|
|
|
# when tests are not run
|
|
|
|
++ lib.optional doInstallCheck cmocka;
|
2021-10-06 13:57:05 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
nativeInstallCheckInputs = [
|
2021-10-06 13:57:05 +00:00
|
|
|
cmocka which openssl procps_pkg iproute2 ibm-sw-tpm2
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-10-06 13:57:05 +00:00
|
|
|
strictDeps = true;
|
2020-06-18 07:06:33 +00:00
|
|
|
preAutoreconf = "./bootstrap";
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
patches = [
|
|
|
|
# Do not rely on dynamic loader path
|
|
|
|
# TCTI loader relies on dlopen(), this patch prefixes all calls with the output directory
|
|
|
|
./no-dynamic-loader-path.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs script
|
|
|
|
substituteInPlace src/tss2-tcti/tctildr-dl.c \
|
|
|
|
--replace '@PREFIX@' $out/lib/
|
|
|
|
substituteInPlace ./test/unit/tctildr-dl.c \
|
2024-05-15 15:35:15 +00:00
|
|
|
--replace '@PREFIX@' $out/lib/
|
2023-07-15 17:15:38 +00:00
|
|
|
substituteInPlace ./bootstrap \
|
|
|
|
--replace 'git describe --tags --always --dirty' 'echo "${version}"'
|
2021-03-09 03:18:52 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
configureFlags = lib.optionals doInstallCheck [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--enable-unit"
|
|
|
|
"--enable-integration"
|
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# Do not install the upstream udev rules, they rely on specific
|
|
|
|
# users/groups which aren't guaranteed to exist on the system.
|
|
|
|
rm -R $out/lib/udev
|
|
|
|
'';
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
doCheck = false;
|
|
|
|
doInstallCheck = stdenv.buildPlatform == stdenv.hostPlatform;
|
|
|
|
# Since we rewrote the load path in the dynamic loader for the TCTI
|
|
|
|
# The various tcti implementation should be placed in their target directory
|
|
|
|
# before we could run tests, so we make turn checkPhase into installCheckPhase
|
|
|
|
installCheckTarget = "check";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "OSS implementation of the TCG TPM2 Software Stack (TSS2)";
|
|
|
|
homepage = "https://github.com/tpm2-software/tpm2-tss";
|
|
|
|
license = licenses.bsd2;
|
|
|
|
platforms = platforms.linux;
|
2023-07-15 17:15:38 +00:00
|
|
|
maintainers = with maintainers; [ baloo ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|