2021-02-24 18:30:23 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2021-12-19 01:06:50 +00:00
|
|
|
, fetchFromGitHub
|
2021-02-24 18:30:23 +00:00
|
|
|
, autoreconfHook
|
|
|
|
, pkg-config
|
2021-09-18 10:52:07 +00:00
|
|
|
, libtasn1, openssl, fuse, glib, libseccomp, json-glib
|
2021-02-24 18:30:23 +00:00
|
|
|
, libtpms
|
|
|
|
, unixtools, expect, socat
|
|
|
|
, gnutls
|
|
|
|
, perl
|
2021-12-19 01:06:50 +00:00
|
|
|
|
|
|
|
# Tests
|
|
|
|
, python3, which
|
2022-02-21 08:47:16 +00:00
|
|
|
, nixosTests
|
2021-02-24 18:30:23 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "swtpm";
|
2022-02-21 08:47:16 +00:00
|
|
|
version = "0.7.1";
|
2021-02-24 18:30:23 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "stefanberger";
|
|
|
|
repo = "swtpm";
|
|
|
|
rev = "v${version}";
|
2022-02-21 08:47:16 +00:00
|
|
|
sha256 = "sha256-LJQF8PlRkhCJ8rjZzDetg1BFuTb7GBJ8lW6u5hO134k=";
|
2021-02-24 18:30:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config unixtools.netstat expect socat
|
|
|
|
perl # for pod2man
|
|
|
|
autoreconfHook
|
|
|
|
];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
checkInputs = [
|
|
|
|
python3 which
|
|
|
|
];
|
|
|
|
|
2021-02-24 18:30:23 +00:00
|
|
|
buildInputs = [
|
|
|
|
libtpms
|
|
|
|
openssl libtasn1 libseccomp
|
2021-09-18 10:52:07 +00:00
|
|
|
fuse glib json-glib
|
2021-02-24 18:30:23 +00:00
|
|
|
gnutls
|
|
|
|
];
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--with-cuse"
|
2021-10-17 02:12:59 +00:00
|
|
|
"--localstatedir=/var"
|
2021-02-24 18:30:23 +00:00
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
postPatch = ''
|
2021-12-19 01:06:50 +00:00
|
|
|
patchShebangs tests/*
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# Makefile tries to create the directory /var/lib/swtpm-localca, which fails
|
2021-10-17 02:12:59 +00:00
|
|
|
substituteInPlace samples/Makefile.am \
|
|
|
|
--replace 'install-data-local:' 'do-not-execute:'
|
|
|
|
|
|
|
|
# Use the correct path to the certtool binary
|
|
|
|
# instead of relying on it being in the environment
|
2021-12-19 01:06:50 +00:00
|
|
|
substituteInPlace src/swtpm_localca/swtpm_localca.c --replace \
|
2021-10-17 02:12:59 +00:00
|
|
|
'# define CERTTOOL_NAME "certtool"' \
|
|
|
|
'# define CERTTOOL_NAME "${gnutls}/bin/certtool"'
|
|
|
|
'';
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
doCheck = true;
|
2021-02-24 18:30:23 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
2022-02-21 08:47:16 +00:00
|
|
|
passthru.tests = { inherit (nixosTests) systemd-cryptenroll; };
|
|
|
|
|
2021-02-24 18:30:23 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Libtpms-based TPM emulator";
|
|
|
|
homepage = "https://github.com/stefanberger/swtpm";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = [ maintainers.baloo ];
|
|
|
|
};
|
|
|
|
}
|