2022-12-17 10:02:37 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, version
|
|
|
|
, hash
|
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;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
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 = [
|
|
|
|
"-DUSE_SHARED_MBEDTLS_LIBRARY=on"
|
|
|
|
|
|
|
|
# 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
|
|
|
|
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";
|
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = platforms.all;
|
2022-12-17 10:02:37 +00:00
|
|
|
maintainers = with maintainers; [ raphaelr ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|