An SMTP client and server library for Zig implementing RFC 5321.
12 kB
332 lines
1# generated by zon2nix (https://github.com/jcollie/zon2nix)
2{
3 lib,
4 linkFarm,
5 fetchzip,
6 fetchurl,
7 fetchgit,
8 runCommandLocal,
9 zig_0_16,
10 zstd,
11 name ? "zig-packages",
12}:
13let
14 unpackZigArtifact =
15 {
16 name,
17 artifact,
18 }:
19 runCommandLocal name
20 {
21 nativeBuildInputs = [ zig_0_16 ];
22 }
23 ''
24 # workaround https://codeberg.org/ziglang/zig/issues/31866
25 # https://github.com/Cloudef/zig2nix/issues/54
26 mkdir "$TMPDIR/src" "$TMPDIR/cache" "$TMPDIR/cache/tmp"
27 touch "$TMPDIR/src/build.zig"
28 hash="$(cd "$TMPDIR/src" && zig fetch --global-cache-dir "$TMPDIR/cache" ${artifact})"
29 mkdir "$out"
30 tar zxvf "$TMPDIR/cache/p/$hash.tar.gz" --directory "$out/" --strip-components=1
31 '';
32
33 fetchZig =
34 {
35 name,
36 url,
37 hash,
38 unpack,
39 }:
40 let
41 artifact =
42 if unpack then
43 fetchzip {
44 inherit url hash;
45 nativeBuildInputs = [ zstd ];
46 }
47 else
48 fetchurl { inherit url hash; };
49 in
50 unpackZigArtifact { inherit name artifact; };
51
52 fetchGitZig =
53 {
54 name,
55 url,
56 hash,
57 }:
58 let
59 parts = lib.splitString "#" url;
60 url_base = builtins.elemAt parts 0;
61 url_without_query = builtins.elemAt (lib.splitString "?" url_base) 0;
62 rev_base = builtins.elemAt parts 1;
63 rev =
64 if builtins.match "^[a-fA-F0-9]{40}$" rev_base != null then rev_base else "refs/heads/${rev_base}";
65 in
66 fetchgit {
67 inherit name rev hash;
68 url = url_without_query;
69 deepClone = false;
70 fetchSubmodules = false;
71 };
72
73 fetchZigArtifact =
74 {
75 name,
76 url,
77 hash,
78 unpack,
79 }:
80 let
81 parts = lib.splitString "://" url;
82 proto = builtins.elemAt parts 0;
83 path = builtins.elemAt parts 1;
84 fetcher = {
85 "git+http" = fetchGitZig {
86 inherit name hash;
87 url = "http://${path}";
88 };
89 "git+https" = fetchGitZig {
90 inherit name hash;
91 url = "https://${path}";
92 };
93 http = fetchZig {
94 inherit name hash unpack;
95 url = "http://${path}";
96 };
97 https = fetchZig {
98 inherit name hash unpack;
99 url = "https://${path}";
100 };
101 };
102 in
103 fetcher.${proto};
104 # The packages, as real directories holding symlinked files, rather than as
105 # a farm of symlinked directories.
106 #
107 # Zig runs a dependency's own build steps with the working directory set to
108 # that dependency, and points at the program to run with a path counted in
109 # directories up from there. Through a symlink the two disagree: Zig counts
110 # from `<farm>/<package>/`, four directories below the root, while the kernel
111 # resolves the working directory to `/nix/store/<hash>`, which is three, so
112 # the path lands one short of where the program is.
113 #
114 # It works anyway when the build directory is `/build`, because the sum then
115 # overshoots into the root and going above the root stays there. It fails
116 # when the build directory is under `/nix/var/nix/builds`, which is where Nix
117 # puts it when the sandbox is off. Real directories make the two depths
118 # agree, so it works either way.
119 #
120 # The files have to be real as well, which is the expensive part and cannot
121 # be avoided. `--symbolic-link` would leave them pointing into each
122 # dependency's own store path, so that the farm is a few megabytes rather
123 # than a second copy of every dependency -- but Zig's
124 # `installHeadersDirectory` walks the directory and copies only the entries
125 # whose kind is `.file`. Symlinked headers are skipped without a word, and
126 # the first thing to include one fails with `'dcimgui.h' not found`.
127 #
128 # `--link` is not the way out. A hard link into a Nix output is a file the
129 # builder did not create: inside the Linux sandbox the store is a separate
130 # mount and `link` fails with `Invalid cross-device link`, while on Darwin it
131 # succeeds and leaves root-owned files in the output, which Nix refuses while
132 # canonicalising with `invalid ownership on file`.
133 #
134 # So it is a real copy, with `--reflink=auto` to share the blocks on a
135 # filesystem that can. `nix store optimise` recovers the duplication after
136 # the fact, hard-linking identical files across the store, which is the
137 # store's own business to do and not a build's.
138 copyFarm =
139 farm: entries: pathDependencyPackages:
140 runCommandLocal farm
141 {
142 # The packages whose own manifest declares a dependency by `.path`.
143 # Zig 0.16.0 cannot build these through `zig build --system`: it spins
144 # in userspace forever, because a `.path` dependency's hash is computed
145 # against the system package directory during the fetch and against the
146 # real global cache afterwards, and in that mode the two disagree. A
147 # package that wants `--system` copies each of these into its build
148 # root and passes `--fork=`; see the README.
149 passthru = { inherit pathDependencyPackages; };
150 }
151 ''
152 mkdir -p "$out"
153 cp --recursive --reflink=auto --dereference --no-preserve=mode \
154 ${linkFarm farm entries}/. "$out/"
155 '';
156in
157copyFarm name
158 [
159 {
160 name = "N-V-__8AAJ77GgCr4jV_q5d8vuaUZIWMrHbXUMYV7il4sgLB";
161 path = fetchZigArtifact {
162 name = "cldr_core";
163 url = "https://registry.npmjs.org/cldr-core/-/cldr-core-48.2.0.tgz";
164 hash = "sha256-UxDgx6BsH+uD3I5UyFhLvgucLqgyAXKhjVQZhrEkWF0=";
165 unpack = false;
166 };
167 }
168 {
169 name = "N-V-__8AAGszqAU24FLBIkgdecxizqeniOtXvaJyJNhnerSV";
170 path = fetchZigArtifact {
171 name = "cldr_dates";
172 url = "https://registry.npmjs.org/cldr-dates-full/-/cldr-dates-full-48.2.0.tgz";
173 hash = "sha256-Albxzv7KFPfVFb5Ict2kj83X51OBQw8lqv0BQ+rltDA=";
174 unpack = false;
175 };
176 }
177 {
178 name = "N-V-__8AAP5iTQJ7vhRS_dLVKhpakujqxJsIbu89VYJgXryk";
179 path = fetchZigArtifact {
180 name = "cldr_numbers";
181 url = "https://registry.npmjs.org/cldr-numbers-full/-/cldr-numbers-full-48.2.0.tgz";
182 hash = "sha256-LRehRTxVmmIRLK7tUuC8/jy4U5yZ0jmue37U0IJ2edk=";
183 unpack = false;
184 };
185 }
186 {
187 name = "datetime-0.0.1-6-va79gDDwCD7vUCwnd8YeSBQlXh5xq-yjnhzeT7VCYw";
188 path = fetchZigArtifact {
189 name = "datetime";
190 url = "git+https://git.jcollie.dev/jeff/zig-datetime.git#bd76e05460dba019f7749e44a37ea5afe6c49609";
191 hash = "sha256-hVLUAc9Mm5HjLSkUURlb4nW2sn78ZvrWKsaC1cdzCuE=";
192 unpack = true;
193 };
194 }
195 {
196 name = "dkim-0.0.0-Fy8_qXbjAwCVPGu8Lx3H__hjGGEkS8O8t_kAAvZytOfr";
197 path = fetchZigArtifact {
198 name = "dkim";
199 url = "git+https://git.jcollie.dev/jeff/zig-dkim.git#0c185dce9f9c59707e146506d021d1da01401020";
200 hash = "sha256-xT7bBJNEZ1UScKHodZa4n5zuMz7A9FbIzl5rkMj6o6g=";
201 unpack = true;
202 };
203 }
204 {
205 name = "N-V-__8AAFtMiwHRrbE2kejFyc1FTFciBTZJlJOPGt-eIVGJ";
206 path = fetchZigArtifact {
207 name = "exim";
208 url = "https://github.com/Exim/exim/archive/13835a3c1e057efad7da269c0f93bf2eac850205.tar.gz";
209 hash = "sha256-mqyGOAONL1uvPWZbraGmBjzrsTRW2424lGae0x9CR1U=";
210 unpack = false;
211 };
212 }
213 {
214 name = "N-V-__8AAI5RBAAIsFSqnDYObnOsBo3t9cQMXnvu0vQQRSAf";
215 path = fetchZigArtifact {
216 name = "isemail";
217 url = "https://github.com/dominicsayers/isemail/archive/cfeefc3f2f88cb195053f6a309fa4f640cd369b5.tar.gz";
218 hash = "sha256-bgW2Lj00UluNZWrydCU7sx9332PmbttAAER4fq5ACmo=";
219 unpack = false;
220 };
221 }
222 {
223 name = "zig_mime-0.0.0-4saPF24RCwBOkIdo4hHfAYfUovszKIL7CXaXgB5gyGC4";
224 path = fetchZigArtifact {
225 name = "mime";
226 url = "git+https://git.jcollie.dev/jeff/zig-mime.git#70ea89ff4e2f1a89315ce0811376bc7103418f4d";
227 hash = "sha256-eE1tK6VjImX8BKxhMOFeIlx3245j/QEnupIAlUO4W5E=";
228 unpack = true;
229 };
230 }
231 {
232 name = "N-V-__8AAHNhQgCiWfjOCo_LQgx55jnHBr2Z61ZAqPU9n5Uo";
233 path = fetchZigArtifact {
234 name = "moment";
235 url = "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz";
236 hash = "sha256-UiGan+5eH6reTHJTbBc8VM7dXiYZJy3QwlGjCur83ow=";
237 unpack = false;
238 };
239 }
240 {
241 name = "sasl-0.0.0-s3YcOPiJAQCy9rnR9LEZY_Zc_x0oK6yc1FUCD57I2jvc";
242 path = fetchZigArtifact {
243 name = "sasl";
244 url = "git+https://git.jcollie.dev/jeff/zig-sasl.git#c6452ffcb932c6cbf34651be2acd694cc18f2fd3";
245 hash = "sha256-6ddHRVnU7Ma6oadl/N+rQD/bgN7YTUljvDt2ZPzlxgw=";
246 unpack = true;
247 };
248 }
249 {
250 name = "std_crypto_ext-0.0.0-zmlw4bc3AwBPVhIG9TPuHlFwfZ0eQ1t24AzQx5ERyIC7";
251 path = fetchZigArtifact {
252 name = "std_crypto_ext";
253 url = "git+https://git.jcollie.dev/jeff/zig-std-crypto-ext.git#1dfbbe87291143823e52d0aca9339ac4b7d62f69";
254 hash = "sha256-8zLut6oDOlt8oonSpYFlM8xSpbltjcbr0rckZIyBv28=";
255 unpack = true;
256 };
257 }
258 {
259 name = "tls-0.1.0-ER2e0jGpBgCkVC-Yp12NgSdHNUtZr52MleJ8roHlUa54";
260 path = fetchZigArtifact {
261 name = "tls";
262 url = "https://github.com/ianic/tls.zig/archive/e04ae448ce7ee70c136d4d48b059314543203809.tar.gz";
263 hash = "sha256-afPTfauIV49IATX0szuOdKLloyqI4XKsyNk8KkasAvg=";
264 unpack = true;
265 };
266 }
267 {
268 name = "N-V-__8AABybDwDd46ZHFqBjb0twea7p9vwNzdSzUHFwA55f";
269 path = fetchZigArtifact {
270 name = "tzcode";
271 url = "https://data.iana.org/time-zones/releases/tzcode2026d.tar.gz";
272 hash = "sha256-L1yff+Kea4y4Y1g2Z4hLjOF7CkhTVaBUtZHGvfzYF5E=";
273 unpack = false;
274 };
275 }
276 {
277 name = "N-V-__8AAFiAFQDNovBNmFwF3hznlSfpY7KwAN3Jy7rhie29";
278 path = fetchZigArtifact {
279 name = "tzdata";
280 url = "https://data.iana.org/time-zones/releases/tzdata2026d.tar.gz";
281 hash = "sha256-DLKqjjM8PcBJutxCoMYfIZh7jNROEH+pALrXZKrMd2c=";
282 unpack = false;
283 };
284 }
285 {
286 name = "uri-0.1.0-yCrwNDeWEQAu6MkfDY_ucBK05hxa6fQTpyzrmAOTXrag";
287 path = fetchZigArtifact {
288 name = "uri";
289 url = "git+https://git.jcollie.dev/jeff/zig-uri.git#8ed08e670ee3c32711bef2f8eadb65726a68e53d";
290 hash = "sha256-jcv24dQLi9WgVHd/m03yUIF0mapDWiV8+PXO1TB2TIE=";
291 unpack = true;
292 };
293 }
294 {
295 name = "uucode-0.2.0-ZZjBPh-6VADBlunHbwABTPng0DH6uJqd4CvvtjZ19tny";
296 path = fetchZigArtifact {
297 name = "uucode";
298 url = "git+https://github.com/jacobsandlund/uucode#61e54266895f833b307de81a0e3038cf1f1bebd4";
299 hash = "sha256-6Riz1CowKgQr70YAcfozHETUqfOR4gYIwUE5txjX70o=";
300 unpack = true;
301 };
302 }
303 {
304 name = "z46-0.1.0-_AxhwBHeAwDelVOsDdnw7Rg1ZzCY2uH99YdFQknXdy1J";
305 path = fetchZigArtifact {
306 name = "z46";
307 url = "git+https://git.jcollie.dev/jeff/z46.git#52bc1256116cde4b3e7480d8664da09e5901490a";
308 hash = "sha256-U2dGmTMhQI+Yc0Zw9K9rGq1vRSqqTOxI51zxbtiI1Bk=";
309 unpack = true;
310 };
311 }
312 {
313 name = "win32-42.0.39-preview-mX5pFS564gPTezZn4v3TMxRnfJUrZNx1B_F2p2HKXOeG";
314 path = fetchZigArtifact {
315 name = "zigwin32";
316 url = "git+https://github.com/marlersoft/zigwin32#9f15c276b4e9d05afd34a10d8662a7dfc34647ea";
317 hash = "sha256-JCmUrieEnOKQViUGjPNrlGwJMMM4X/BjC3iur5fRbqA=";
318 unpack = true;
319 };
320 }
321 {
322 name = "zuucode-0.0.0-0vGVIUdzAQB9KHmXYgy0yzxjZly9shdXSHUnxDYo8hCc";
323 path = fetchZigArtifact {
324 name = "zuucode";
325 url = "git+https://git.jcollie.dev/jeff/zuucode.git#702a8aeec6251961cc880d1a2539ad72714f6881";
326 hash = "sha256-qWNdJ9igjZ0pF902vheTA1o9MQ1TS9tHr2ajJ3vNKD0=";
327 unpack = true;
328 };
329 }
330 ]
331 [
332 ]