Skip to content

Commit 1046367

Browse files
committed
refactor(libstore): deprecate legacy s3 support
1 parent 66983c6 commit 1046367

File tree

12 files changed

+42
-874
lines changed

12 files changed

+42
-874
lines changed

src/libstore-tests/filetransfer-s3.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "nix/store/filetransfer.hh"
22
#include "nix/store/config.hh"
33

4-
#if NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT
4+
#if NIX_WITH_AWS_CRT_SUPPORT
55

66
# include <gtest/gtest.h>
77
# include <gmock/gmock.h>
@@ -159,4 +159,4 @@ TEST_F(S3FileTransferTest, regionExtraction)
159159

160160
} // namespace nix
161161

162-
#endif // NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT
162+
#endif // NIX_WITH_AWS_CRT_SUPPORT

src/libstore-tests/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ sources = files(
7575
'path-info.cc',
7676
'path.cc',
7777
'references.cc',
78-
's3-binary-cache-store.cc',
7978
's3-edge-cases.cc',
8079
's3-http-integration.cc',
8180
'serve-protocol.cc',

src/libstore-tests/s3-binary-cache-store.cc

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/libstore-tests/s3-edge-cases.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "nix/store/aws-auth.hh"
33
#include "nix/store/config.hh"
44

5-
#if NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT
5+
#if NIX_WITH_AWS_CRT_SUPPORT
66

77
# include <gtest/gtest.h>
88
# include <gmock/gmock.h>
@@ -259,4 +259,4 @@ TEST_F(S3EdgeCasesTest, curlOptions_VerifyS3Configuration)
259259

260260
} // namespace nix
261261

262-
#endif // NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT
262+
#endif // NIX_WITH_AWS_CRT_SUPPORT

src/libstore-tests/s3-http-integration.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "nix/store/filetransfer.hh"
22
#include "nix/store/config.hh"
33

4-
#if NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT
4+
#if NIX_WITH_AWS_CRT_SUPPORT
55

66
# include <gtest/gtest.h>
77
# include <gmock/gmock.h>
@@ -201,4 +201,4 @@ TEST_F(S3HttpIntegrationTest, compatibility_BackwardCompatible)
201201

202202
} // namespace nix
203203

204-
#endif // NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT
204+
#endif // NIX_WITH_AWS_CRT_SUPPORT

src/libstore/filetransfer.cc

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "nix/store/globals.hh"
33
#include "nix/util/config-global.hh"
44
#include "nix/store/store-api.hh"
5-
#include "nix/store/s3.hh"
65
#include "nix/util/compression.hh"
76
#include "nix/util/finally.hh"
87
#include "nix/util/callback.hh"
@@ -11,9 +10,6 @@
1110
#include "nix/util/url.hh"
1211

1312
#include "store-config-private.hh"
14-
#if NIX_WITH_S3_SUPPORT
15-
# include <aws/core/client/ClientConfiguration.h>
16-
#endif
1713
#if NIX_WITH_AWS_CRT_SUPPORT
1814
# include "nix/store/aws-auth.hh"
1915
#endif
@@ -144,7 +140,7 @@ struct curlFileTransfer : public FileTransfer
144140
requestHeaders = curl_slist_append(requestHeaders, fmt("%s: %s", it->first, it->second).c_str());
145141
}
146142

147-
#if NIX_WITH_AWS_CRT_SUPPORT && NIX_WITH_S3_SUPPORT
143+
#if NIX_WITH_AWS_CRT_SUPPORT
148144
// Handle S3 URLs with curl-based AWS SigV4 authentication
149145
if (hasPrefix(request.uri, "s3://")) {
150146
try {
@@ -485,8 +481,9 @@ struct curlFileTransfer : public FileTransfer
485481
curl_easy_setopt(req, CURLOPT_ERRORBUFFER, errbuf);
486482
errbuf[0] = 0;
487483

488-
#if NIX_WITH_AWS_CRT_SUPPORT && LIBCURL_VERSION_NUM >= 0x074b00 // curl 7.75.0
484+
#if NIX_WITH_AWS_CRT_SUPPORT
489485
// 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)
490487
if (isS3Request && !awsCredentials.empty() && !awsSigV4Provider.empty()) {
491488
curl_easy_setopt(req, CURLOPT_USERPWD, awsCredentials.c_str());
492489
curl_easy_setopt(req, CURLOPT_AWS_SIGV4, awsSigV4Provider.c_str());
@@ -866,7 +863,7 @@ struct curlFileTransfer : public FileTransfer
866863
#endif
867864
}
868865

869-
#if NIX_WITH_S3_SUPPORT
866+
#if NIX_WITH_AWS_CRT_SUPPORT
870867
/**
871868
* Parsed S3 URL with convenience methods for parameter access and HTTPS conversion
872869
*/
@@ -956,37 +953,15 @@ struct curlFileTransfer : public FileTransfer
956953

957954
void enqueueFileTransfer(const FileTransferRequest & request, Callback<FileTransferResult> callback) override
958955
{
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 */
960957
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
963960
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-
}
988961
#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);
990965
#endif
991966
return;
992967
}

src/libstore/include/nix/store/meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ headers = [ config_pub_h ] + files(
6868
'remote-store-connection.hh',
6969
'remote-store.hh',
7070
'restricted-store.hh',
71-
's3-binary-cache-store.hh',
72-
's3.hh',
7371
'serve-protocol-connection.hh',
7472
'serve-protocol-impl.hh',
7573
'serve-protocol.hh',

src/libstore/include/nix/store/s3-binary-cache-store.hh

Lines changed: 0 additions & 137 deletions
This file was deleted.

src/libstore/include/nix/store/s3.hh

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)