7 , buildShared ? !stdenv.hostPlatform.isStatic
11 ldLibPathEnvName = if stdenv.isDarwin
12 then "DYLD_LIBRARY_PATH"
13 else "LD_LIBRARY_PATH";
19 , knownVulnerabilities ? []
20 }: stdenv.mkDerivation rec
26 url = "mirror://openbsd/LibreSSL/${pname}-${version}.tar.gz";
30 nativeBuildInputs = [ cmake ];
34 # Ensure that the output libraries do not require an executable stack.
35 # Without this define, assembly files in libcrypto do not include a
36 # .note.GNU-stack section, and if that section is missing from any object,
37 # the linker will make the stack executable.
38 "-DCMAKE_C_FLAGS=-DHAVE_GNU_STACK"
39 # libressl will append this to the regular prefix for libdir
40 "-DCMAKE_INSTALL_LIBDIR=lib"
41 ] ++ lib.optional buildShared "-DBUILD_SHARED_LIBS=ON";
43 # The autoconf build is broken as of 2.9.1, resulting in the following error:
44 # libressl-2.9.1/tls/.libs/libtls.a', needed by 'handshake_table'.
45 # Fortunately LibreSSL provides a CMake build as well, so opt for CMake by
46 # removing ./configure pre-config.
49 substituteInPlace CMakeLists.txt \
50 --replace 'exec_prefix \''${prefix}' "exec_prefix ${placeholder "bin"}" \
51 --replace 'libdir \''${exec_prefix}' 'libdir \''${prefix}'
56 # Since 2.9.x the default location can't be configured from the build using
57 # DEFAULT_CA_FILE anymore, instead we have to patch the default value.
60 ${lib.optionalString (lib.versionAtLeast version "2.9.2") ''
61 substituteInPlace ./tls/tls_config.c --replace '"/etc/ssl/cert.pem"' '"${cacert}/etc/ssl/certs/ca-bundle.crt"'
65 doCheck = !(stdenv.hostPlatform.isPower64 || stdenv.hostPlatform.isRiscV);
67 export PREVIOUS_${ldLibPathEnvName}=$${ldLibPathEnvName}
68 export ${ldLibPathEnvName}="$${ldLibPathEnvName}:$(realpath tls/):$(realpath ssl/):$(realpath crypto/)"
71 export ${ldLibPathEnvName}=$PREVIOUS_${ldLibPathEnvName}
74 outputs = [ "bin" "dev" "out" "man" "nc" ];
77 moveToOutput "bin/nc" "$nc"
78 moveToOutput "bin/openssl" "$bin"
79 moveToOutput "bin/ocspcheck" "$bin"
80 moveToOutput "share/man/man1/nc.1.gz" "$nc"
84 description = "Free TLS/SSL implementation";
85 homepage = "https://www.libressl.org";
86 license = with licenses; [ publicDomain bsdOriginal bsd0 bsd3 gpl3 isc openssl ];
87 platforms = platforms.all;
88 maintainers = with maintainers; [ thoughtpolice fpletz ];
89 inherit knownVulnerabilities;
94 libressl_3_6 = generic {
96 hash = "sha256-h7G7426e7I0K5fBMg9NrLFsOWBeEx+sIFwJe0p6t6jc=";
99 libressl_3_7 = generic {
101 hash = "sha256-eUjIVqkMglvXJotvhWdKjc0lS65C4iF4GyTj+NwzXbM=";
104 libressl_3_8 = generic {
106 hash = "sha256-bUuNW7slofgzZjnlbsUIgFLUOpUlZpeoXEzpEyPCWVQ=";