An SMTP client and server library for Zig implementing RFC 5321.
3.3 kB
133 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"
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};
104in
105linkFarm name [
106 {
107 name = "N-V-__8AAFtMiwHRrbE2kejFyc1FTFciBTZJlJOPGt-eIVGJ";
108 path = fetchZigArtifact {
109 name = "exim";
110 url = "https://github.com/Exim/exim/archive/13835a3c1e057efad7da269c0f93bf2eac850205.tar.gz";
111 hash = "sha256-mqyGOAONL1uvPWZbraGmBjzrsTRW2424lGae0x9CR1U=";
112 unpack = false;
113 };
114 }
115 {
116 name = "N-V-__8AAI5RBAAIsFSqnDYObnOsBo3t9cQMXnvu0vQQRSAf";
117 path = fetchZigArtifact {
118 name = "isemail";
119 url = "https://github.com/dominicsayers/isemail/archive/cfeefc3f2f88cb195053f6a309fa4f640cd369b5.tar.gz";
120 hash = "sha256-bgW2Lj00UluNZWrydCU7sx9332PmbttAAER4fq5ACmo=";
121 unpack = false;
122 };
123 }
124 {
125 name = "tls-0.1.0-ER2e0jGpBgCkVC-Yp12NgSdHNUtZr52MleJ8roHlUa54";
126 path = fetchZigArtifact {
127 name = "tls";
128 url = "https://github.com/ianic/tls.zig/archive/e04ae448ce7ee70c136d4d48b059314543203809.tar.gz";
129 hash = "sha256-afPTfauIV49IATX0szuOdKLloyqI4XKsyNk8KkasAvg=";
130 unpack = true;
131 };
132 }
133]