11#include " nix/store/s3-binary-cache-store.hh"
2-
3- #include < cassert>
4-
52#include " nix/store/http-binary-cache-store.hh"
63#include " nix/store/store-registration.hh"
74
5+ #include < cassert>
6+ #include < ranges>
7+
88namespace nix {
99
1010StringSet S3BinaryCacheStoreConfig::uriSchemes ()
@@ -17,19 +17,31 @@ S3BinaryCacheStoreConfig::S3BinaryCacheStoreConfig(
1717 : StoreConfig(params)
1818 , HttpBinaryCacheStoreConfig(scheme, _cacheUri, params)
1919{
20- // For S3 stores, preserve S3-specific query parameters as part of the URL
21- // These are needed for region specification and other S3-specific settings
2220 assert (cacheUri.query .empty ());
21+ assert (cacheUri.scheme == " s3" );
2322
24- // Only copy S3-specific parameters to the URL query
25- static const std::set<std::string> s3Params = {" region" , " endpoint" , " profile" , " scheme" };
2623 for (const auto & [key, value] : params) {
27- if (s3Params.contains (key)) {
24+ auto s3Params =
25+ std::views::transform (s3UriSettings, [](const AbstractSetting * setting) { return setting->name ; });
26+ if (std::ranges::contains (s3Params, key)) {
2827 cacheUri.query [key] = value;
2928 }
3029 }
3130}
3231
32+ std::string S3BinaryCacheStoreConfig::getHumanReadableURI () const
33+ {
34+ auto reference = getReference ();
35+ reference.params = [&]() {
36+ Params relevantParams;
37+ for (auto & setting : s3UriSettings)
38+ if (setting->overridden )
39+ relevantParams.insert ({setting->name , reference.params .at (setting->name )});
40+ return relevantParams;
41+ }();
42+ return reference.render ();
43+ }
44+
3345std::string S3BinaryCacheStoreConfig::doc ()
3446{
3547 return R"(
0 commit comments