mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Move S3 URL parsing, store configuration, and public bucket support outside of NIX_WITH_S3_SUPPORT guards. Only AWS credential resolution remains gated, allowing builds with withAWS = false to: - Parse s3:// URLs - Register S3 store types - Access public S3 buckets (via HTTPS conversion) - Use S3-compatible services without authentication The setupForS3() function now always performs URL conversion, with authentication code conditionally compiled based on NIX_WITH_S3_SUPPORT. The aws-creds.cc file (only code using AWS CRT SDK) is now conditionally compiled by meson.
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
#include "nix/store/s3-binary-cache-store.hh"
|
|
|
|
#include <cassert>
|
|
|
|
#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
|