A maildir and Maildir++ library for Zig 0.16: delivery, flags, folders and quota.
8.3 kB
242 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 = "zig_mime-0.0.0-4saPF8Z6BQB9wid4v2A2LrT_OyhQYZUwQDx7aCdpm0Hc";
197 path = fetchZigArtifact {
198 name = "mime";
199 url = "git+https://git.jcollie.dev/jeff/zig-mime.git#efdb9e8a7fd4a2d9c8318c663771832289259e89";
200 hash = "sha256-Q8B/Rdb4GuxEdwhbdrRPeYq5B81ulgijTbujBkclG80=";
201 unpack = true;
202 };
203 }
204 {
205 name = "N-V-__8AAHNhQgCiWfjOCo_LQgx55jnHBr2Z61ZAqPU9n5Uo";
206 path = fetchZigArtifact {
207 name = "moment";
208 url = "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz";
209 hash = "sha256-UiGan+5eH6reTHJTbBc8VM7dXiYZJy3QwlGjCur83ow=";
210 unpack = false;
211 };
212 }
213 {
214 name = "N-V-__8AABybDwDd46ZHFqBjb0twea7p9vwNzdSzUHFwA55f";
215 path = fetchZigArtifact {
216 name = "tzcode";
217 url = "https://data.iana.org/time-zones/releases/tzcode2026d.tar.gz";
218 hash = "sha256-L1yff+Kea4y4Y1g2Z4hLjOF7CkhTVaBUtZHGvfzYF5E=";
219 unpack = false;
220 };
221 }
222 {
223 name = "N-V-__8AAFiAFQDNovBNmFwF3hznlSfpY7KwAN3Jy7rhie29";
224 path = fetchZigArtifact {
225 name = "tzdata";
226 url = "https://data.iana.org/time-zones/releases/tzdata2026d.tar.gz";
227 hash = "sha256-DLKqjjM8PcBJutxCoMYfIZh7jNROEH+pALrXZKrMd2c=";
228 unpack = false;
229 };
230 }
231 {
232 name = "win32-42.0.39-preview-mX5pFS564gPTezZn4v3TMxRnfJUrZNx1B_F2p2HKXOeG";
233 path = fetchZigArtifact {
234 name = "zigwin32";
235 url = "git+https://github.com/marlersoft/zigwin32#9f15c276b4e9d05afd34a10d8662a7dfc34647ea";
236 hash = "sha256-JCmUrieEnOKQViUGjPNrlGwJMMM4X/BjC3iur5fRbqA=";
237 unpack = true;
238 };
239 }
240 ]
241 [
242 ]