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