9 # The primary --enable-XXX variant. 'all' enables most features, but causes build-errors for some software,
10 # requiring to build a special variant for that software. Example: 'haproxy'
12 , extraConfigureFlags ? []
13 , enableARMCryptoExtensions ? stdenv.hostPlatform.isAarch64 && ((builtins.match "^.*\\+crypto.*$" stdenv.hostPlatform.gcc.arch) != null)
14 , enableLto ? !(stdenv.hostPlatform.isStatic || stdenv.cc.isClang)
16 stdenv.mkDerivation (finalAttrs: {
17 pname = "wolfssl-${variant}";
20 src = fetchFromGitHub {
23 rev = "refs/tags/v${finalAttrs.version}-stable";
24 hash = "sha256-/dtW1E1wYfQEuotclUEOK5+Vg4S7vt1xWhr1lEtu60w=";
28 patchShebangs ./scripts
29 # ensure test detects musl-based systems too
30 substituteInPlace scripts/ocsp-stapling2.test \
31 --replace '"linux-gnu"' '"linux-"'
36 "--enable-reproducible-build"
37 ] ++ lib.optionals (variant == "all") [
38 # Extra feature flags to add while building the 'all' variant.
39 # Since they conflict while building other variants, only specify them for this one.
42 "--enable-base64encode"
44 # We're not on tiny embedded machines.
45 # Increase TLS session cache from 33 sessions to 20k.
48 # Use WolfSSL's Single Precision Math with timing-resistant cryptography.
49 "--enable-sp=yes${lib.optionalString (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isAarch) ",asm"}"
50 "--enable-sp-math-all"
52 ] ++ lib.optionals (stdenv.hostPlatform.isx86_64) [
53 # Enable AVX/AVX2/AES-NI instructions, gated by runtime detection via CPUID.
56 ] ++ lib.optionals (stdenv.hostPlatform.isAarch64) [
57 # No runtime detection under ARM and no platform function checks like for X86.
58 (if enableARMCryptoExtensions
59 then "--enable-armasm=inline"
60 else "--disable-armasm")
61 ] ++ extraConfigureFlags;
63 # Breaks tls13 tests on aarch64-darwin.
64 hardeningDisable = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ "zerocallusedregs" ];
66 # LTO should help with the C implementations.
67 env.NIX_CFLAGS_COMPILE = lib.optionalString enableLto "-flto";
68 env.NIX_LDFLAGS_COMPILE = lib.optionalString enableLto "-flto";
70 # Don't attempt connections to external services in the test suite.
71 env.WOLFSSL_EXTERNAL_TEST = "0";
80 propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
97 # fix recursive cycle:
98 # wolfssl-config points to dev, dev propagates bin
99 moveToOutput bin/wolfssl-config "$dev"
100 # moveToOutput also removes "$out" so recreate it
105 description = "Small, fast, portable implementation of TLS/SSL for embedded devices";
106 mainProgram = "wolfssl-config";
107 homepage = "https://www.wolfssl.com/";
108 changelog = "https://github.com/wolfSSL/wolfssl/releases/tag/v${finalAttrs.version}-stable";
109 platforms = platforms.all;
110 license = licenses.gpl2Plus;
111 maintainers = with maintainers; [ fab vifino ];