nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, cmake
6, curl
7, openssl
8, s2n-tls
9, zlib
10, aws-crt-cpp
11, aws-c-cal
12, aws-c-common
13, aws-c-event-stream
14, aws-c-io
15, aws-checksums
16, CoreAudio
17, AudioToolbox
18, # Allow building a limited set of APIs, e.g. ["s3" "ec2"].
19 apis ? ["*"]
20, # Whether to enable AWS' custom memory management.
21 customMemoryManagement ? true
22}:
23
24let
25 host_os = if stdenv.hostPlatform.isDarwin then "APPLE"
26 else if stdenv.hostPlatform.isAndroid then "ANDROID"
27 else if stdenv.hostPlatform.isWindows then "WINDOWS"
28 else if stdenv.hostPlatform.isLinux then "LINUX"
29 else throw "Unknown host OS";
30in
31
32stdenv.mkDerivation rec {
33 pname = "aws-sdk-cpp";
34 version = if stdenv.system == "i686-linux" then "1.9.150"
35 else "1.9.238";
36
37 src = fetchFromGitHub {
38 owner = "aws";
39 repo = "aws-sdk-cpp";
40 rev = version;
41 sha256 = if version == "1.9.150" then "fgLdXWQKHaCwulrw9KV3vpQ71DjnQAL4heIRW7Rk7UY="
42 else "sha256-pEmsTfZXsvJMV79dGkjDNbUVajwyoYgzE5DCsC53pGY=";
43 };
44
45 postPatch = ''
46 # Missing includes for GCC11
47 sed '5i#include <thread>' -i \
48 aws-cpp-sdk-cloudfront-integration-tests/CloudfrontOperationTest.cpp \
49 aws-cpp-sdk-cognitoidentity-integration-tests/IdentityPoolOperationTest.cpp \
50 aws-cpp-sdk-dynamodb-integration-tests/TableOperationTest.cpp \
51 aws-cpp-sdk-elasticfilesystem-integration-tests/ElasticFileSystemTest.cpp \
52 aws-cpp-sdk-lambda-integration-tests/FunctionTest.cpp \
53 aws-cpp-sdk-mediastore-data-integration-tests/MediaStoreDataTest.cpp \
54 aws-cpp-sdk-queues/source/sqs/SQSQueue.cpp \
55 aws-cpp-sdk-redshift-integration-tests/RedshiftClientTest.cpp \
56 aws-cpp-sdk-s3-crt-integration-tests/BucketAndObjectOperationTest.cpp \
57 aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp \
58 aws-cpp-sdk-s3control-integration-tests/S3ControlTest.cpp \
59 aws-cpp-sdk-sqs-integration-tests/QueueOperationTest.cpp \
60 aws-cpp-sdk-transfer-tests/TransferTests.cpp
61 # Flaky on Hydra
62 rm aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp
63 # Includes aws-c-auth private headers, so only works with submodule build
64 rm aws-cpp-sdk-core-tests/aws/auth/AWSAuthSignerTest.cpp
65 '' + lib.optionalString stdenv.hostPlatform.isMusl ''
66 # TestRandomURLMultiThreaded fails
67 rm aws-cpp-sdk-core-tests/http/HttpClientTest.cpp
68 '';
69
70 # FIXME: might be nice to put different APIs in different outputs
71 # (e.g. libaws-cpp-sdk-s3.so in output "s3").
72 outputs = [ "out" "dev" ];
73
74 nativeBuildInputs = [ cmake curl ];
75
76 buildInputs = [
77 curl openssl zlib
78 ] ++ lib.optionals (stdenv.isDarwin &&
79 ((builtins.elem "text-to-speech" apis) ||
80 (builtins.elem "*" apis)))
81 [ CoreAudio AudioToolbox ];
82
83 # propagation is needed for Security.framework to be available when linking
84 propagatedBuildInputs = [ aws-crt-cpp ];
85
86 cmakeFlags = [
87 "-DBUILD_DEPS=OFF"
88 "-DCMAKE_SKIP_BUILD_RPATH=OFF"
89 ] ++ lib.optional (!customMemoryManagement) "-DCUSTOM_MEMORY_MANAGEMENT=0"
90 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
91 "-DENABLE_TESTING=OFF"
92 "-DCURL_HAS_H2=1"
93 "-DCURL_HAS_TLS_PROXY=1"
94 "-DTARGET_ARCH=${host_os}"
95 ] ++ lib.optional (apis != ["*"])
96 "-DBUILD_ONLY=${lib.concatStringsSep ";" apis}";
97
98 # fix build with gcc9, can be removed after bumping to current version
99 NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
100
101 # aws-cpp-sdk-core-tests/aws/client/AWSClientTest.cpp
102 # seem to have a datarace
103 enableParallelChecking = false;
104
105 postFixupHooks = [
106 # This bodge is necessary so that the file that the generated -config.cmake file
107 # points to an existing directory.
108 "mkdir -p $out/include"
109 ];
110
111 __darwinAllowLocalNetworking = true;
112
113 patches = [
114 ./cmake-dirs.patch
115 ]
116 ++ lib.optional (lib.versionOlder version "1.9.163")
117 (fetchpatch {
118 url = "https://github.com/aws/aws-sdk-cpp/commit/b102aaf5693c4165c84b616ab9ffb9edfb705239.diff";
119 sha256 = "sha256-38QBo3MEFpyHPb8jZEURRPkoeu4DqWhVeErJayiHKF0=";
120 });
121
122 # Builds in 2+h with 2 cores, and ~10m with a big-parallel builder.
123 requiredSystemFeatures = [ "big-parallel" ];
124
125 meta = with lib; {
126 description = "A C++ interface for Amazon Web Services";
127 homepage = "https://github.com/aws/aws-sdk-cpp";
128 license = licenses.asl20;
129 platforms = platforms.unix;
130 maintainers = with maintainers; [ eelco orivej ];
131 };
132}