1{ lib, stdenv, fetchFromGitHub, cmake, curl, openssl, zlib, fetchpatch
2, aws-c-common, aws-c-event-stream, 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.7.90";
13
14 src = fetchFromGitHub {
15 owner = "awslabs";
16 repo = "aws-sdk-cpp";
17 rev = version;
18 sha256 = "0zpqi612qmm0n53crxiisv0vdif43ymg13kafy6vv43j2wmh66ga";
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 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 cmakeFlags = [
36 "-DBUILD_DEPS=OFF"
37 "-DCMAKE_SKIP_BUILD_RPATH=OFF"
38 ] ++ lib.optional (!customMemoryManagement) "-DCUSTOM_MEMORY_MANAGEMENT=0"
39 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
40 "-DENABLE_TESTING=OFF"
41 "-DCURL_HAS_H2=0"
42 ] ++ lib.optional (apis != ["*"])
43 "-DBUILD_ONLY=${lib.concatStringsSep ";" apis}";
44
45 # fix build with gcc9, can be removed after bumping to current version
46 NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
47
48 preConfigure =
49 ''
50 rm aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp
51 '';
52
53 postFixupHooks = [
54 # This bodge is necessary so that the file that the generated -config.cmake file
55 # points to an existing directory.
56 ''mkdir -p $out/include''
57 ];
58
59 __darwinAllowLocalNetworking = true;
60
61 patches = [
62 (fetchpatch {
63 url = "https://github.com/aws/aws-sdk-cpp/commit/42991ab549087c81cb630e5d3d2413e8a9cf8a97.patch";
64 sha256 = "0myq5cm3lvl5r56hg0sc0zyn1clbkd9ys0wr95ghw6bhwpvfv8gr";
65 })
66 ./cmake-dirs.patch
67 ];
68
69 meta = with lib; {
70 description = "A C++ interface for Amazon Web Services";
71 homepage = "https://github.com/awslabs/aws-sdk-cpp";
72 license = licenses.asl20;
73 platforms = platforms.unix;
74 maintainers = with maintainers; [ eelco orivej ];
75 };
76}