2022-12-04 14:53:16 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, version
|
|
|
|
, hash
|
2018-06-28 20:25:19 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
|
|
|
|
, cmake
|
|
|
|
, ninja
|
|
|
|
, perl # Project uses Perl for scripting and testing
|
2021-03-26 09:51:06 +00:00
|
|
|
, python3
|
2018-06-28 20:25:19 +00:00
|
|
|
|
|
|
|
, enableThreading ? true # Threading can be disabled to increase security https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
|
|
|
|
}:
|
2015-04-06 21:41:54 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "mbedtls";
|
2022-12-04 14:53:16 +00:00
|
|
|
inherit version;
|
2015-04-06 21:41:54 +00:00
|
|
|
|
2018-01-28 01:10:04 +00:00
|
|
|
src = fetchFromGitHub {
|
2022-12-04 14:53:16 +00:00
|
|
|
owner = "Mbed-TLS";
|
2018-01-28 01:10:04 +00:00
|
|
|
repo = "mbedtls";
|
2019-08-15 12:41:18 +00:00
|
|
|
rev = "${pname}-${version}";
|
2022-12-04 14:53:16 +00:00
|
|
|
inherit hash;
|
2015-04-06 21:41:54 +00:00
|
|
|
};
|
|
|
|
|
2021-03-26 09:51:06 +00:00
|
|
|
nativeBuildInputs = [ cmake ninja perl python3 ];
|
|
|
|
|
|
|
|
strictDeps = true;
|
2016-12-10 16:29:50 +00:00
|
|
|
|
2021-08-18 00:14:20 +00:00
|
|
|
postConfigure = lib.optionalString enableThreading ''
|
2018-06-28 20:25:19 +00:00
|
|
|
perl scripts/config.pl set MBEDTLS_THREADING_C # Threading abstraction layer
|
|
|
|
perl scripts/config.pl set MBEDTLS_THREADING_PTHREAD # POSIX thread wrapper layer for the threading layer.
|
2016-12-10 16:29:50 +00:00
|
|
|
'';
|
|
|
|
|
2022-12-14 22:12:02 +00:00
|
|
|
cmakeFlags = [
|
2022-12-26 06:14:11 +00:00
|
|
|
"-DUSE_SHARED_MBEDTLS_LIBRARY=${if stdenv.hostPlatform.isStatic then "off" else "on"}"
|
2022-12-14 22:12:02 +00:00
|
|
|
|
|
|
|
# Avoid a dependency on jsonschema and jinja2 by not generating source code
|
|
|
|
# using python. In releases, these generated files are already present in
|
|
|
|
# the repository and do not need to be regenerated. See:
|
|
|
|
# https://github.com/Mbed-TLS/mbedtls/releases/tag/v3.3.0 below "Requirement changes".
|
|
|
|
"-DGEN_FILES=off"
|
2021-04-18 23:52:18 +00:00
|
|
|
];
|
2015-04-06 21:41:54 +00:00
|
|
|
|
2023-08-06 10:22:57 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
# Parallel checking causes test failures
|
|
|
|
# https://github.com/Mbed-TLS/mbedtls/issues/4980
|
|
|
|
enableParallelChecking = false;
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2022-12-04 14:53:16 +00:00
|
|
|
homepage = "https://www.trustedfirmware.org/projects/mbed-tls/";
|
|
|
|
changelog = "https://github.com/Mbed-TLS/mbedtls/blob/${pname}-${version}/ChangeLog";
|
2018-06-28 20:25:19 +00:00
|
|
|
description = "Portable cryptographic and TLS library, formerly known as PolarSSL";
|
2023-11-09 07:37:26 +00:00
|
|
|
license = [ licenses.asl20 /* or */ licenses.gpl2Plus ];
|
2015-04-06 21:41:54 +00:00
|
|
|
platforms = platforms.all;
|
2022-12-04 14:53:16 +00:00
|
|
|
maintainers = with maintainers; [ raphaelr ];
|
2015-04-06 21:41:54 +00:00
|
|
|
};
|
|
|
|
}
|