2022-12-17 10:02:37 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, version
|
|
|
|
, hash
|
2024-04-21 15:54:59 +00:00
|
|
|
, patches ? []
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
|
|
|
|
, cmake
|
|
|
|
, ninja
|
|
|
|
, perl # Project uses Perl for scripting and testing
|
2021-04-05 15:23:46 +00:00
|
|
|
, python3
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, enableThreading ? true # Threading can be disabled to increase security https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "mbedtls";
|
2022-12-17 10:02:37 +00:00
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-12-17 10:02:37 +00:00
|
|
|
owner = "Mbed-TLS";
|
2020-04-24 23:36:52 +00:00
|
|
|
repo = "mbedtls";
|
|
|
|
rev = "${pname}-${version}";
|
2022-12-17 10:02:37 +00:00
|
|
|
inherit hash;
|
2024-04-21 15:54:59 +00:00
|
|
|
# mbedtls >= 3.6.0 uses git submodules
|
|
|
|
fetchSubmodules = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
inherit patches;
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
nativeBuildInputs = [ cmake ninja perl python3 ];
|
|
|
|
|
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
postConfigure = lib.optionalString enableThreading ''
|
2020-04-24 23:36:52 +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.
|
|
|
|
'';
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
cmakeFlags = [
|
2022-12-28 21:21:41 +00:00
|
|
|
"-DUSE_SHARED_MBEDTLS_LIBRARY=${if stdenv.hostPlatform.isStatic then "off" else "on"}"
|
2022-12-17 10:02:37 +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-22 02:08:21 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
# Parallel checking causes test failures
|
|
|
|
# https://github.com/Mbed-TLS/mbedtls/issues/4980
|
|
|
|
enableParallelChecking = false;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2022-12-17 10:02:37 +00:00
|
|
|
homepage = "https://www.trustedfirmware.org/projects/mbed-tls/";
|
|
|
|
changelog = "https://github.com/Mbed-TLS/mbedtls/blob/${pname}-${version}/ChangeLog";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Portable cryptographic and TLS library, formerly known as PolarSSL";
|
2024-01-25 14:12:00 +00:00
|
|
|
license = [ licenses.asl20 /* or */ licenses.gpl2Plus ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
2022-12-17 10:02:37 +00:00
|
|
|
maintainers = with maintainers; [ raphaelr ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|