1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

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
This commit is contained in:
Bernardo Meurer Costa 2025-10-03 00:45:49 +00:00
parent 8a8a0c2a4b
commit 27f6417128
No known key found for this signature in database
8 changed files with 45 additions and 6 deletions

View file

@ -1,7 +1,7 @@
#include "nix/store/s3-url.hh" #include "nix/store/s3-url.hh"
#include "nix/util/tests/gmock-matchers.hh" #include "nix/util/tests/gmock-matchers.hh"
#if NIX_WITH_S3_SUPPORT #if NIX_WITH_S3_SUPPORT || NIX_WITH_CURL_S3
# include <gtest/gtest.h> # include <gtest/gtest.h>
# include <gmock/gmock.h> # include <gmock/gmock.h>

View file

@ -1,6 +1,6 @@
#include "nix/store/aws-creds.hh" #include "nix/store/aws-creds.hh"
#if NIX_WITH_S3_SUPPORT #if NIX_WITH_CURL_S3
# include <aws/crt/Types.h> # include <aws/crt/Types.h>
# include "nix/store/s3-url.hh" # include "nix/store/s3-url.hh"

View file

@ -2,7 +2,7 @@
///@file ///@file
#include "nix/store/config.hh" #include "nix/store/config.hh"
#if NIX_WITH_S3_SUPPORT #if NIX_WITH_CURL_S3
# include "nix/store/s3-url.hh" # include "nix/store/s3-url.hh"
# include "nix/util/error.hh" # include "nix/util/error.hh"

View file

@ -2,7 +2,7 @@
///@file ///@file
#include "nix/store/config.hh" #include "nix/store/config.hh"
#if NIX_WITH_S3_SUPPORT #if NIX_WITH_S3_SUPPORT || NIX_WITH_CURL_S3
# include "nix/util/url.hh" # include "nix/util/url.hh"
# include "nix/util/util.hh" # include "nix/util/util.hh"

View file

@ -164,6 +164,33 @@ if aws_s3.found()
endif endif
deps_other += aws_s3 deps_other += aws_s3
# Curl-based S3 store support (alternative to AWS SDK)
# Check if curl supports AWS SigV4 (requires >= 7.75.0)
curl_supports_aws_sigv4 = curl.version().version_compare('>= 7.75.0')
# AWS CRT C++ for lightweight credential management
aws_crt_cpp = cxx.find_library('aws-crt-cpp', required : false)
curl_s3_store_opt = get_option('curl-s3-store').require(
curl_supports_aws_sigv4,
error_message : 'curl-based S3 support requires curl >= 7.75.0',
).require(
aws_crt_cpp.found(),
error_message : 'curl-based S3 support requires aws-crt-cpp',
)
# Make AWS SDK and curl-based S3 mutually exclusive
if aws_s3.found() and curl_s3_store_opt.enabled()
error(
'Cannot enable both AWS SDK S3 support and curl-based S3 support. Please choose one.',
)
endif
if curl_s3_store_opt.enabled()
deps_other += aws_crt_cpp
endif
configdata_pub.set('NIX_WITH_CURL_S3', curl_s3_store_opt.enabled().to_int())
subdir('nix-meson-build-support/generate-header') subdir('nix-meson-build-support/generate-header')
generated_headers = [] generated_headers = []

View file

@ -33,3 +33,10 @@ option(
value : '/nix/var/log/nix', value : '/nix/var/log/nix',
description : 'path to store logs in for Nix', description : 'path to store logs in for Nix',
) )
option(
'curl-s3-store',
type : 'feature',
value : 'disabled',
description : 'Enable curl-based S3 binary cache store support (requires aws-crt-cpp and curl >= 7.75.0)',
)

View file

@ -10,6 +10,7 @@
boost, boost,
curl, curl,
aws-sdk-cpp, aws-sdk-cpp,
aws-crt-cpp,
libseccomp, libseccomp,
nlohmann_json, nlohmann_json,
sqlite, sqlite,
@ -25,6 +26,8 @@
withAWS ? withAWS ?
# Default is this way because there have been issues building this dependency # Default is this way because there have been issues building this dependency
stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin), stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin),
withCurlS3 ? false,
}: }:
let let
@ -64,7 +67,8 @@ mkMesonLibrary (finalAttrs: {
sqlite sqlite
] ]
++ lib.optional stdenv.hostPlatform.isLinux libseccomp ++ lib.optional stdenv.hostPlatform.isLinux libseccomp
++ lib.optional withAWS aws-sdk-cpp; ++ lib.optional withAWS aws-sdk-cpp
++ lib.optional withCurlS3 aws-crt-cpp;
propagatedBuildInputs = [ propagatedBuildInputs = [
nix-util nix-util
@ -74,6 +78,7 @@ mkMesonLibrary (finalAttrs: {
mesonFlags = [ mesonFlags = [
(lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux) (lib.mesonEnable "seccomp-sandboxing" stdenv.hostPlatform.isLinux)
(lib.mesonBool "embedded-sandbox-shell" embeddedSandboxShell) (lib.mesonBool "embedded-sandbox-shell" embeddedSandboxShell)
(lib.mesonEnable "curl-s3-store" withCurlS3)
] ]
++ lib.optionals stdenv.hostPlatform.isLinux [ ++ lib.optionals stdenv.hostPlatform.isLinux [
(lib.mesonOption "sandbox-shell" "${busybox-sandbox-shell}/bin/busybox") (lib.mesonOption "sandbox-shell" "${busybox-sandbox-shell}/bin/busybox")

View file

@ -1,6 +1,6 @@
#include "nix/store/s3-url.hh" #include "nix/store/s3-url.hh"
#if NIX_WITH_S3_SUPPORT #if NIX_WITH_S3_SUPPORT || NIX_WITH_CURL_S3
# include "nix/util/error.hh" # include "nix/util/error.hh"
# include "nix/util/split.hh" # include "nix/util/split.hh"