1{ lib, stdenv, fetchFromGitHub, cmake, curl, openssl, zlib
2, # Allow building a limited set of APIs, e.g. ["s3" "ec2"].
3 apis ? ["*"]
4, # Whether to enable AWS' custom memory management.
5 customMemoryManagement ? true
6}:
7
8let
9 loaderVar =
10 if stdenv.isLinux
11 then "LD_LIBRARY_PATH"
12 else if stdenv.isDarwin
13 then "DYLD_LIBRARY_PATH"
14 else throw "Unsupported system!";
15in stdenv.mkDerivation rec {
16 name = "aws-sdk-cpp-${version}";
17 version = "1.1.18";
18
19 src = fetchFromGitHub {
20 owner = "awslabs";
21 repo = "aws-sdk-cpp";
22 rev = version;
23 sha256 = "1i85zpns3gj5by45ppg4rfk9csix8mjazpyj6dqic40b2wshnw8c";
24 };
25
26 # FIXME: might be nice to put different APIs in different outputs
27 # (e.g. libaws-cpp-sdk-s3.so in output "s3").
28 outputs = [ "out" "dev" ];
29 separateDebugInfo = stdenv.isLinux;
30
31 buildInputs = [ cmake curl ];
32
33 cmakeFlags =
34 lib.optional (!customMemoryManagement) "-DCUSTOM_MEMORY_MANAGEMENT=0"
35 ++ lib.optional (apis != ["*"])
36 "-DBUILD_ONLY=${lib.concatStringsSep ";" apis}";
37
38 enableParallelBuilding = true;
39
40 # Behold the escaping nightmare below on loaderVar o.O
41 preBuild =
42 ''
43 # Ensure that the unit tests can find the *.so files.
44 for i in testing-resources aws-cpp-sdk-*; do
45 export ${loaderVar}=$(pwd)/$i:''${${loaderVar}}
46 done
47 '';
48
49 preConfigure =
50 ''
51 rm aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp
52 '';
53
54 NIX_LDFLAGS = lib.concatStringsSep " " (
55 (map (pkg: "-rpath ${lib.getOutput "lib" pkg}/lib"))
56 [ curl openssl zlib stdenv.cc.cc ]);
57
58 meta = {
59 description = "A C++ interface for Amazon Web Services";
60 homepage = https://github.com/awslabs/aws-sdk-cpp;
61 license = lib.licenses.asl20;
62 platforms = lib.platforms.linux ++ lib.platforms.darwin;
63 maintainers = [ lib.maintainers.eelco ];
64 };
65}