Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
s3-binary-cache-store.hh
Go to the documentation of this file.
1#pragma once
3
4#include "nix/store/config.hh"
6#include "nix/store/s3-url.hh"
7
8namespace nix {
9
10struct S3BinaryCacheStoreConfig : HttpBinaryCacheStoreConfig
11{
12 S3BinaryCacheStoreConfig(const Params & params)
14 , HttpBinaryCacheStoreConfig(params)
15 {
16 }
17
18 S3BinaryCacheStoreConfig(ParsedURL cacheUri, const Params & params);
19
20 S3BinaryCacheStoreConfig(std::string_view bucketName, const Params & params);
21
23 this,
24 "default",
25 "profile",
26 R"(
27 The name of the AWS configuration profile to use. By default
28 Nix uses the `default` profile.
29 )"};
30
32 this,
33 "us-east-1",
34 "region",
35 R"(
36 The region of the S3 bucket. If your bucket is not in
37 `us-east-1`, you should always explicitly specify the region
38 parameter.
39 )"};
40
42 this,
43 "https",
44 "scheme",
45 R"(
46 Deprecated: specify the scheme as part of the `endpoint` URL
47 instead, e.g. `endpoint=http://localhost:9000`.
48
49 The scheme used for S3 requests, `https` (default) or `http`. This
50 option allows you to disable HTTPS for binary caches which don't
51 support it.
52
53 > **Note**
54 >
55 > HTTPS should be used if the cache might contain sensitive
56 > information.
57 )"};
58
59 Setting<std::string> endpoint{
60 this,
61 "",
62 "endpoint",
63 R"(
64 The S3 endpoint to use. When empty (default), uses AWS S3 with
65 region-specific endpoints. For S3-compatible services such as
66 MinIO, set this to your service's endpoint as a full URL,
67 e.g. `https://minio.example.com` or `http://localhost:9000`.
68 )"};
69
70 Setting<S3AddressingStyle> addressingStyle{
71 this,
72 S3AddressingStyle::Auto,
73 "addressing-style",
74 R"(
75 The S3 addressing style to use. `auto` (default) uses
76 virtual-hosted-style for standard AWS endpoints and path-style
77 for custom endpoints; bucket names containing dots automatically
78 fall back to path-style to avoid TLS certificate errors. `path`
79 forces path-style addressing (deprecated by AWS). `virtual`
80 forces virtual-hosted-style addressing (bucket names must not
81 contain dots).
82 )"};
83
84 Setting<bool> multipartUpload{
85 this,
86 false,
87 "multipart-upload",
88 R"(
89 Whether to use multipart uploads for large files. When enabled,
90 files exceeding the multipart threshold will be uploaded in
91 multiple parts, which is required for files larger than 5 GiB and
92 can improve performance and reliability for large uploads.
93 )"};
94
95 Setting<uint64_t> multipartChunkSize{
96 this,
97 5 * 1024 * 1024,
98 "multipart-chunk-size",
99 R"(
100 The size (in bytes) of each part in multipart uploads. Must be
101 at least 5 MiB (AWS S3 requirement). Larger chunk sizes reduce the
102 number of requests but use more memory. Default is 5 MiB.
103 )",
104 {"buffer-size"}};
105
106 Setting<uint64_t> multipartThreshold{
107 this,
108 100 * 1024 * 1024,
109 "multipart-threshold",
110 R"(
111 The minimum file size (in bytes) for using multipart uploads.
112 Files smaller than this threshold will use regular PUT requests.
113 Default is 100 MiB. Only takes effect when multipart-upload is enabled.
114 )"};
115
117 this,
118 std::nullopt,
119 "storage-class",
120 R"(
121 The S3 storage class to use for uploaded objects. When not set (default),
122 uses the bucket's default storage class. Valid values include:
123 - STANDARD (default, frequently accessed data)
124 - REDUCED_REDUNDANCY (less frequently accessed data)
125 - STANDARD_IA (infrequent access)
126 - ONEZONE_IA (infrequent access, single AZ)
127 - INTELLIGENT_TIERING (automatic cost optimization)
128 - GLACIER (archival with retrieval times in minutes to hours)
129 - DEEP_ARCHIVE (long-term archival with 12-hour retrieval)
130 - GLACIER_IR (instant retrieval archival)
131
132 See AWS S3 documentation for detailed storage class descriptions and pricing:
133 https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-class-intro.html
134 )"};
135
140 const std::set<const AbstractSetting *> s3UriSettings = {&profile, &region, &scheme, &endpoint, &addressingStyle};
141
142 static const std::string name()
143 {
144 return "S3 Binary Cache Store";
145 }
146
147 static StringSet uriSchemes();
148
149 static std::string doc();
150
151 std::string getHumanReadableURI() const override;
152
153 ref<Store> openStore() const override;
154};
155
156} // namespace nix
Definition configuration.hh:476
Definition url.hh:22
std::string getHumanReadableURI() const override
Definition s3-binary-cache-store.cc:466
ref< Store > openStore() const override
Definition s3-binary-cache-store.cc:486
const std::set< const AbstractSetting * > s3UriSettings
Definition s3-binary-cache-store.hh:140
@ Unix
Definition store-api.hh:131
Definition store-api.hh:240
static std::string doc()
Definition store-api.hh:258