1{ lib, stdenv, fetchFromGitHub, cmake, curl, openssl, s2n-tls, zlib
2, aws-crt-cpp
3, aws-c-cal, aws-c-common, aws-c-event-stream, aws-c-io, aws-checksums
4, CoreAudio, AudioToolbox
5, # Allow building a limited set of APIs, e.g. ["s3" "ec2"].
6 apis ? ["*"]
7, # Whether to enable AWS' custom memory management.
8 customMemoryManagement ? true
9}:
10
11let
12 host_os = if stdenv.hostPlatform.isDarwin then "APPLE"
13 else if stdenv.hostPlatform.isAndroid then "ANDROID"
14 else if stdenv.hostPlatform.isWindows then "WINDOWS"
15 else if stdenv.hostPlatform.isLinux then "LINUX"
16 else throw "Unknown host OS";
17in
18
19stdenv.mkDerivation rec {
20 pname = "aws-sdk-cpp";
21 version = "1.9.121";
22
23 src = fetchFromGitHub {
24 owner = "awslabs";
25 repo = "aws-sdk-cpp";
26 rev = version;
27 sha256 = "sha256-VQpWauk0tdJ1QU0HmtdTwQdKbiAuTTXXsUo2cqpqmdU=";
28 };
29
30 postPatch = ''
31 # Flaky on Hydra
32 rm aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp
33 # Includes aws-c-auth private headers, so only works with submodule build
34 rm aws-cpp-sdk-core-tests/aws/auth/AWSAuthSignerTest.cpp
35 '' + lib.optionalString stdenv.hostPlatform.isMusl ''
36 # TestRandomURLMultiThreaded fails
37 rm aws-cpp-sdk-core-tests/http/HttpClientTest.cpp
38 '';
39
40 # FIXME: might be nice to put different APIs in different outputs
41 # (e.g. libaws-cpp-sdk-s3.so in output "s3").
42 outputs = [ "out" "dev" ];
43
44 nativeBuildInputs = [ cmake curl ];
45
46 buildInputs = [
47 curl openssl zlib
48 ] ++ lib.optionals (stdenv.isDarwin &&
49 ((builtins.elem "text-to-speech" apis) ||
50 (builtins.elem "*" apis)))
51 [ CoreAudio AudioToolbox ];
52
53 # propagation is needed for Security.framework to be available when linking
54 propagatedBuildInputs = [ aws-crt-cpp ];
55
56 cmakeFlags = [
57 "-DBUILD_DEPS=OFF"
58 "-DCMAKE_SKIP_BUILD_RPATH=OFF"
59 ] ++ lib.optional (!customMemoryManagement) "-DCUSTOM_MEMORY_MANAGEMENT=0"
60 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
61 "-DENABLE_TESTING=OFF"
62 "-DCURL_HAS_H2=1"
63 "-DCURL_HAS_TLS_PROXY=1"
64 "-DTARGET_ARCH=${host_os}"
65 ] ++ lib.optional (apis != ["*"])
66 "-DBUILD_ONLY=${lib.concatStringsSep ";" apis}";
67
68 # fix build with gcc9, can be removed after bumping to current version
69 NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
70
71 # aws-cpp-sdk-core-tests/aws/client/AWSClientTest.cpp
72 # seem to have a datarace
73 enableParallelChecking = false;
74
75 postFixupHooks = [
76 # This bodge is necessary so that the file that the generated -config.cmake file
77 # points to an existing directory.
78 "mkdir -p $out/include"
79 ];
80
81 __darwinAllowLocalNetworking = true;
82
83 patches = [
84 ./cmake-dirs.patch
85 ];
86
87 # Builds in 2+h with 2 cores, and ~10m with a big-parallel builder.
88 requiredSystemFeatures = [ "big-parallel" ];
89
90 meta = with lib; {
91 description = "A C++ interface for Amazon Web Services";
92 homepage = "https://github.com/awslabs/aws-sdk-cpp";
93 license = licenses.asl20;
94 platforms = platforms.unix;
95 maintainers = with maintainers; [ eelco orivej ];
96 };
97}