mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
feat(libstore): add curl-based S3 store implementation
Add a new S3BinaryCacheStore implementation that inherits from HttpBinaryCacheStore. The implementation is activated with NIX_WITH_CURL_S3, keeping the existing NIX_WITH_S3_SUPPORT (AWS SDK) implementation unchanged.
This commit is contained in:
parent
dfafd8bc38
commit
0855b715a9
3 changed files with 248 additions and 0 deletions
|
|
@ -589,4 +589,50 @@ static RegisterStoreImplementation<S3BinaryCacheStoreImpl::Config> regS3BinaryCa
|
|||
|
||||
} // namespace nix
|
||||
|
||||
#elif NIX_WITH_CURL_S3
|
||||
|
||||
# include <cassert>
|
||||
|
||||
# include "nix/store/s3-binary-cache-store.hh"
|
||||
# include "nix/store/http-binary-cache-store.hh"
|
||||
# include "nix/store/store-registration.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
StringSet S3BinaryCacheStoreConfig::uriSchemes()
|
||||
{
|
||||
return {"s3"};
|
||||
}
|
||||
|
||||
S3BinaryCacheStoreConfig::S3BinaryCacheStoreConfig(
|
||||
std::string_view scheme, std::string_view _cacheUri, const Params & params)
|
||||
: StoreConfig(params)
|
||||
, HttpBinaryCacheStoreConfig(scheme, _cacheUri, params)
|
||||
{
|
||||
// For S3 stores, preserve S3-specific query parameters as part of the URL
|
||||
// These are needed for region specification and other S3-specific settings
|
||||
assert(cacheUri.query.empty());
|
||||
|
||||
// Only copy S3-specific parameters to the URL query
|
||||
static const std::set<std::string> s3Params = {"region", "endpoint", "profile", "scheme"};
|
||||
for (const auto & [key, value] : params) {
|
||||
if (s3Params.contains(key)) {
|
||||
cacheUri.query[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string S3BinaryCacheStoreConfig::doc()
|
||||
{
|
||||
return R"(
|
||||
**Store URL format**: `s3://bucket-name`
|
||||
|
||||
This store allows reading and writing a binary cache stored in an AWS S3 bucket.
|
||||
)";
|
||||
}
|
||||
|
||||
static RegisterStoreImplementation<S3BinaryCacheStoreConfig> registerS3BinaryCacheStore;
|
||||
|
||||
} // namespace nix
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue