about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/aws-c-cal
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/aws-c-cal')
-rw-r--r--nixpkgs/pkgs/development/libraries/aws-c-cal/aws-c-cal-musl-compat.patch33
-rw-r--r--nixpkgs/pkgs/development/libraries/aws-c-cal/default.nix40
2 files changed, 73 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/aws-c-cal/aws-c-cal-musl-compat.patch b/nixpkgs/pkgs/development/libraries/aws-c-cal/aws-c-cal-musl-compat.patch
new file mode 100644
index 000000000000..2cf1d4e81e0b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/aws-c-cal/aws-c-cal-musl-compat.patch
@@ -0,0 +1,33 @@
+From: Emil Lerch <emil@lerch.org>
+Date: Wed, 28 Apr 2021 17:46:24 -0700
+Subject: [PATCH] Allow dlopen to fail on musl systems
+
+Now that references are forced when linking statically, the assertion is
+no longer necessary. See https://github.com/awslabs/aws-c-cal/pull/54
+---
+ source/unix/openssl_platform_init.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/source/unix/openssl_platform_init.c b/source/unix/openssl_platform_init.c
+index 5266ecc1..99f210bd 100644
+--- a/source/unix/openssl_platform_init.c
++++ b/source/unix/openssl_platform_init.c
+@@ -496,7 +502,6 @@ static enum aws_libcrypto_version s_resolve_libcrypto(void) {
+     /* Try to auto-resolve against what's linked in/process space */
+     FLOGF("searching process and loaded modules");
+     void *process = dlopen(NULL, RTLD_NOW);
+-    AWS_FATAL_ASSERT(process && "Unable to load symbols from process space");
+     enum aws_libcrypto_version result = s_resolve_libcrypto_symbols(AWS_LIBCRYPTO_LC, process);
+     if (result == AWS_LIBCRYPTO_NONE) {
+         result = s_resolve_libcrypto_symbols(AWS_LIBCRYPTO_1_0_2, process);
+@@ -504,7 +509,9 @@ static enum aws_libcrypto_version s_resolve_libcrypto(void) {
+     if (result == AWS_LIBCRYPTO_NONE) {
+         result = s_resolve_libcrypto_symbols(AWS_LIBCRYPTO_1_1_1, process);
+     }
+-    dlclose(process);
++    if (process) {
++        dlclose(process);
++    }
+ 
+     if (result == AWS_LIBCRYPTO_NONE) {
+         FLOGF("libcrypto symbols were not statically linked, searching for shared libraries");
diff --git a/nixpkgs/pkgs/development/libraries/aws-c-cal/default.nix b/nixpkgs/pkgs/development/libraries/aws-c-cal/default.nix
new file mode 100644
index 000000000000..0188c8937c90
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/aws-c-cal/default.nix
@@ -0,0 +1,40 @@
+{ lib, stdenv, fetchFromGitHub, cmake, aws-c-common, nix, openssl, Security }:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "aws-c-cal";
+  version = "0.6.10";
+
+  src = fetchFromGitHub {
+    owner = "awslabs";
+    repo = finalAttrs.pname;
+    rev = "v${finalAttrs.version}";
+    hash = "sha256-rzJypIf0DrKI/2Wt5vFop34dL+KYTeCfWC0RflZpiMo=";
+  };
+
+  patches = [
+    # Fix openssl adaptor code for musl based static binaries.
+    ./aws-c-cal-musl-compat.patch
+  ];
+
+  nativeBuildInputs = [ cmake ];
+
+  buildInputs = [ aws-c-common openssl ];
+
+  propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ Security ];
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=ON"
+  ];
+
+  passthru.tests = {
+    inherit nix;
+  };
+
+  meta = with lib; {
+    description = "AWS Crypto Abstraction Layer ";
+    homepage = "https://github.com/awslabs/aws-c-cal";
+    license = licenses.asl20;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ orivej ];
+  };
+})