Skip to content

Commit 27f6417

Browse files
committed
build(libstore): add NIX_WITH_CURL_S3 build option
Introduce a new build option 'curl-s3-store' for the curl-based S3 implementation, separate from the existing AWS SDK-based 's3-store'. The two options are mutually exclusive to avoid conflicts. Users can enable the new implementation with: -Dcurl-s3-store=enabled -Ds3-store=disabled
1 parent 8a8a0c2 commit 27f6417

File tree

8 files changed

+45
-6
lines changed

8 files changed

+45
-6
lines changed

src/libstore-tests/s3-url.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "nix/store/s3-url.hh"
22
#include "nix/util/tests/gmock-matchers.hh"
33

4-
#if NIX_WITH_S3_SUPPORT
4+
#if NIX_WITH_S3_SUPPORT || NIX_WITH_CURL_S3
55

66
# include <gtest/gtest.h>
77
# include <gmock/gmock.h>

src/libstore/aws-creds.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "nix/store/aws-creds.hh"
22

3-
#if NIX_WITH_S3_SUPPORT
3+
#if NIX_WITH_CURL_S3
44

55
# include <aws/crt/Types.h>
66
# include "nix/store/s3-url.hh"

src/libstore/include/nix/store/aws-creds.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
///@file
33
#include "nix/store/config.hh"
44

5-
#if NIX_WITH_S3_SUPPORT
5+
#if NIX_WITH_CURL_S3
66

77
# include "nix/store/s3-url.hh"
88
# include "nix/util/error.hh"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
///@file
33
#include "nix/store/config.hh"
44

5-
#if NIX_WITH_S3_SUPPORT
5+
#if NIX_WITH_S3_SUPPORT || NIX_WITH_CURL_S3
66

77
# include "nix/util/url.hh"
88
# include "nix/util/util.hh"

src/libstore/meson.build

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,33 @@ if aws_s3.found()
164164
endif
165165
deps_other += aws_s3
166166

167+
# Curl-based S3 store support (alternative to AWS SDK)
168+
# Check if curl supports AWS SigV4 (requires >= 7.75.0)
169+
curl_supports_aws_sigv4 = curl.version().version_compare('>= 7.75.0')
170+
# AWS CRT C++ for lightweight credential management
171+
aws_crt_cpp = cxx.find_library('aws-crt-cpp', required : false)
172+
173+
curl_s3_store_opt = get_option('curl-s3-store').require(
174+
curl_supports_aws_sigv4,
175+
error_message : 'curl-based S3 support requires curl >= 7.75.0',
176+
).require(
177+
aws_crt_cpp.found(),
178+
error_message : 'curl-based S3 support requires aws-crt-cpp',
179+
)
180+
181+
# Make AWS SDK and curl-based S3 mutually exclusive
182+
if aws_s3.found() and curl_s3_store_opt.enabled()
183+
error(
184+
'Cannot enable both AWS SDK S3 support and curl-based S3 support. Please choose one.',
185+
)
186+
endif
187+
188+
if curl_s3_store_opt.enabled()
189+
deps_other += aws_crt_cpp
190+
endif
191+
192+
configdata_pub.set('NIX_WITH_CURL_S3', curl_s3_store_opt.enabled().to_int())
193+
167194
subdir('nix-meson-build-support/generate-header')
168195

169196
generated_headers = []

src/libstore/meson.options

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ option(
3333
value : '/nix/var/log/nix',
3434
description : 'path to store logs in for Nix',
3535
)
36+
37+
option(
38+
'curl-s3-store',
39+
type : 'feature',
40+
value : 'disabled',
41+
description : 'Enable curl-based S3 binary cache store support (requires aws-crt-cpp and curl >= 7.75.0)',
42+
)

src/libstore/package.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
boost,
1111
curl,
1212
aws-sdk-cpp,
13+
aws-crt-cpp,
1314
libseccomp,
1415
nlohmann_json,
1516
sqlite,
@@ -25,6 +26,8 @@
2526
withAWS ?
2627
# Default is this way because there have been issues building this dependency
2728
stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin),
29+
30+
withCurlS3 ? false,
2831
}:
2932

3033
let
@@ -64,7 +67,8 @@ mkMesonLibrary (finalAttrs: {
6467
sqlite
6568
]
6669
++ lib.optional stdenv.hostPlatform.isLinux libseccomp
67-
++ lib.optional withAWS aws-sdk-cpp;
70+
++ lib.optional withAWS aws-sdk-cpp
71+
++ lib.optional withCurlS3 aws-crt-cpp;
6872

6973
propagatedBuildInputs = [
7074
nix-util
@@ -74,6 +78,7 @@ mkMesonLibrary (finalAttrs: {
7478
mesonFlags = [
7579
(lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux)
7680
(lib.mesonBool "embedded-sandbox-shell" embeddedSandboxShell)
81+
(lib.mesonEnable "curl-s3-store" withCurlS3)
7782
]
7883
++ lib.optionals stdenv.hostPlatform.isLinux [
7984
(lib.mesonOption "sandbox-shell" "${busybox-sandbox-shell}/bin/busybox")

src/libstore/s3-url.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "nix/store/s3-url.hh"
22

3-
#if NIX_WITH_S3_SUPPORT
3+
#if NIX_WITH_S3_SUPPORT || NIX_WITH_CURL_S3
44

55
# include "nix/util/error.hh"
66
# include "nix/util/split.hh"

0 commit comments

Comments
 (0)