-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
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.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
4 comments
on commit 9ff9c3f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edolstra this is very cool, thanks. Can binary cache retrievals also use this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binary cache retrievals don't need this because you can already use s3://<bucketName>
as a binary cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, cool, didn't realize that already worked. I'll have to try that out, thanks again!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/creating-a-derivation-from-aws-s3-files/16869/2
Why is it linux-only?