|
2 | 2 | #include "nix/store/globals.hh"
|
3 | 3 | #include "nix/util/config-global.hh"
|
4 | 4 | #include "nix/store/store-api.hh"
|
5 |
| -#include "nix/store/s3.hh" |
6 | 5 | #include "nix/util/compression.hh"
|
7 | 6 | #include "nix/util/finally.hh"
|
8 | 7 | #include "nix/util/callback.hh"
|
|
11 | 10 | #include "nix/util/url.hh"
|
12 | 11 |
|
13 | 12 | #include "store-config-private.hh"
|
14 |
| -#if NIX_WITH_S3_SUPPORT |
15 |
| -# include <aws/core/client/ClientConfiguration.h> |
16 |
| -#endif |
17 | 13 | #if NIX_WITH_AWS_CRT_SUPPORT
|
18 | 14 | # include "nix/store/aws-auth.hh"
|
19 | 15 | #endif
|
@@ -144,7 +140,7 @@ struct curlFileTransfer : public FileTransfer
|
144 | 140 | requestHeaders = curl_slist_append(requestHeaders, fmt("%s: %s", it->first, it->second).c_str());
|
145 | 141 | }
|
146 | 142 |
|
147 |
| -#if NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT |
| 143 | +#if NIX_WITH_AWS_CRT_SUPPORT |
148 | 144 | // Handle S3 URLs with curl-based AWS SigV4 authentication
|
149 | 145 | if (hasPrefix(request.uri, "s3://")) {
|
150 | 146 | try {
|
@@ -485,8 +481,9 @@ struct curlFileTransfer : public FileTransfer
|
485 | 481 | curl_easy_setopt(req, CURLOPT_ERRORBUFFER, errbuf);
|
486 | 482 | errbuf[0] = 0;
|
487 | 483 |
|
488 |
| -#if NIX_WITH_AWS_CRT_SUPPORT && LIBCURL_VERSION_NUM >= 0x074b00 // curl 7.75.0 |
| 484 | +#if NIX_WITH_AWS_CRT_SUPPORT |
489 | 485 | // Set up AWS SigV4 authentication if this is an S3 request
|
| 486 | + // Note: AWS SigV4 support guaranteed available (curl >= 7.75.0 checked at build time) |
490 | 487 | if (isS3Request && !awsCredentials.empty() && !awsSigV4Provider.empty()) {
|
491 | 488 | curl_easy_setopt(req, CURLOPT_USERPWD, awsCredentials.c_str());
|
492 | 489 | curl_easy_setopt(req, CURLOPT_AWS_SIGV4, awsSigV4Provider.c_str());
|
@@ -866,7 +863,7 @@ struct curlFileTransfer : public FileTransfer
|
866 | 863 | #endif
|
867 | 864 | }
|
868 | 865 |
|
869 |
| -#if NIX_WITH_S3_SUPPORT |
| 866 | +#if NIX_WITH_AWS_CRT_SUPPORT |
870 | 867 | /**
|
871 | 868 | * Parsed S3 URL with convenience methods for parameter access and HTTPS conversion
|
872 | 869 | */
|
@@ -956,37 +953,15 @@ struct curlFileTransfer : public FileTransfer
|
956 | 953 |
|
957 | 954 | void enqueueFileTransfer(const FileTransferRequest & request, Callback<FileTransferResult> callback) override
|
958 | 955 | {
|
959 |
| - /* Handle s3:// URIs with curl-based AWS SigV4 authentication or fall back to legacy S3Helper */ |
| 956 | + /* Handle s3:// URIs with curl-based AWS SigV4 authentication */ |
960 | 957 | if (hasPrefix(request.uri, "s3://")) {
|
961 |
| -#if NIX_WITH_AWS_CRT_SUPPORT && LIBCURL_VERSION_NUM >= 0x074b00 |
962 |
| - // Use new curl-based approach with AWS SigV4 authentication |
| 958 | +#if NIX_WITH_AWS_CRT_SUPPORT |
| 959 | + // Use curl-based approach with AWS SigV4 authentication |
963 | 960 | enqueueItem(std::make_shared<TransferItem>(*this, request, std::move(callback)));
|
964 |
| -#elif NIX_WITH_S3_SUPPORT |
965 |
| - // Fall back to legacy S3Helper approach |
966 |
| - // FIXME: do this on a worker thread |
967 |
| - try { |
968 |
| - auto s3Parsed = this->parseS3Url(request.uri); |
969 |
| - |
970 |
| - std::string profile = getOr(s3Parsed.params, "profile", ""); |
971 |
| - std::string region = getOr(s3Parsed.params, "region", Aws::Region::US_EAST_1); |
972 |
| - std::string scheme = getOr(s3Parsed.params, "scheme", ""); |
973 |
| - std::string endpoint = getOr(s3Parsed.params, "endpoint", ""); |
974 |
| - |
975 |
| - S3Helper s3Helper(profile, region, scheme, endpoint); |
976 |
| - |
977 |
| - // FIXME: implement ETag |
978 |
| - auto s3Res = s3Helper.getObject(s3Parsed.bucket, s3Parsed.key); |
979 |
| - FileTransferResult res; |
980 |
| - if (!s3Res.data) |
981 |
| - throw FileTransferError(NotFound, {}, "S3 object '%s' does not exist", request.uri); |
982 |
| - res.data = std::move(*s3Res.data); |
983 |
| - res.urls.push_back(request.uri); |
984 |
| - callback(std::move(res)); |
985 |
| - } catch (...) { |
986 |
| - callback.rethrow(); |
987 |
| - } |
988 | 961 | #else
|
989 |
| - throw nix::Error("cannot download '%s' because Nix is not built with S3 support", request.uri); |
| 962 | + throw nix::Error( |
| 963 | + "cannot download '%s' because Nix is not built with AWS CRT support (requires aws-crt-cpp and curl >= 7.75.0)", |
| 964 | + request.uri); |
990 | 965 | #endif
|
991 | 966 | return;
|
992 | 967 | }
|
|
0 commit comments