lol
1{ lib, stdenv
2, fetchFromGitHub
3
4, cmake
5, ninja
6, perl # Project uses Perl for scripting and testing
7, python3
8
9, enableThreading ? true # Threading can be disabled to increase security https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
10}:
11
12stdenv.mkDerivation rec {
13 pname = "mbedtls";
14 # Auto updates are disabled due to repology listing dev releases as release
15 # versions. See
16 # * https://github.com/NixOS/nixpkgs/pull/119838#issuecomment-822100428
17 # * https://github.com/NixOS/nixpkgs/commit/0ee02a9d42b5fe1825b0f7cee7a9986bb4ba975d
18 version = "2.26.0"; # nixpkgs-update: no auto update
19
20 src = fetchFromGitHub {
21 owner = "ARMmbed";
22 repo = "mbedtls";
23 rev = "${pname}-${version}";
24 sha256 = "0scwpmrgvg6q7rvqkc352d2fqlsx0aylcbyibcp1f1rsn8iiif2m";
25 };
26
27 nativeBuildInputs = [ cmake ninja perl python3 ];
28
29 strictDeps = true;
30
31 postConfigure = lib.optionalString enableThreading ''
32 perl scripts/config.pl set MBEDTLS_THREADING_C # Threading abstraction layer
33 perl scripts/config.pl set MBEDTLS_THREADING_PTHREAD # POSIX thread wrapper layer for the threading layer.
34 '';
35
36 cmakeFlags = [ "-DUSE_SHARED_MBEDTLS_LIBRARY=on" ];
37 NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [
38 "-Wno-error=format"
39 "-Wno-error=format-truncation"
40 ];
41
42 meta = with lib; {
43 homepage = "https://tls.mbed.org/";
44 description = "Portable cryptographic and TLS library, formerly known as PolarSSL";
45 license = licenses.asl20;
46 platforms = platforms.all;
47 maintainers = with maintainers; [ fpletz ];
48 };
49}