about summary refs log tree commit diff
path: root/src/libstore/s3.hh
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-02-14T13·20+0100
committerEelco Dolstra <edolstra@gmail.com>2017-02-14T13·20+0100
commit9ff9c3f2f80ba4108e9c945bbfda2c64735f987b (patch)
tree7ce169da649ca6e0a0cd88d6b85544d5c6038e95 /src/libstore/s3.hh
parent62ff5ad424547630e70f35406da85fbb5ec3445a (diff)
Add support for s3:// URIs
This adds support for s3:// URIs in all places where Nix allows URIs,
e.g. in builtins.fetchurl, builtins.fetchTarball, <nix/fetchurl.nix>
and NIX_PATH. It allows fetching resources from private S3 buckets,
using credentials obtained from the standard places (i.e. AWS_*
environment variables, ~/.aws/credentials and the EC2 metadata
server). This may not be super-useful in general, but since we already
depend on aws-sdk-cpp, it's a cheap feature to add.
Diffstat (limited to 'src/libstore/s3.hh')
-rw-r--r--src/libstore/s3.hh33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libstore/s3.hh b/src/libstore/s3.hh
new file mode 100644
index 000000000000..5d5d3475c449
--- /dev/null
+++ b/src/libstore/s3.hh
@@ -0,0 +1,33 @@
+#pragma once
+
+#if ENABLE_S3
+
+#include "ref.hh"
+
+namespace Aws { namespace Client { class ClientConfiguration; } }
+namespace Aws { namespace S3 { class S3Client; } }
+
+namespace nix {
+
+struct S3Helper
+{
+    ref<Aws::Client::ClientConfiguration> config;
+    ref<Aws::S3::S3Client> client;
+
+    S3Helper();
+
+    ref<Aws::Client::ClientConfiguration> makeConfig();
+
+    struct DownloadResult
+    {
+        std::shared_ptr<std::string> data;
+        unsigned int durationMs;
+    };
+
+    DownloadResult getObject(
+        const std::string & bucketName, const std::string & key);
+};
+
+}
+
+#endif