-
Notifications
You must be signed in to change notification settings - Fork 56
/
patches.nix
339 lines (312 loc) · 10.6 KB
/
patches.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# This file contains a list of manually defined manifest patches.
# These are used to update or transform manifests to suit the specific needs of each package.
# Patches are applied if their condition is met in the order they are defined in this list.
{pkgs}: let
forc-plugins = [
"forc-client"
"forc-crypto"
"forc-debug"
"forc-doc"
"forc-fmt"
"forc-lsp"
"forc-tx"
];
in [
# By default, most packages have their `Cargo.lock` file in the repo root.
# We also specify a base, minimum Rust version. This version should never
# change in order to avoid invalidating the cache for all previously built
# packages. Instead, if a new version of a fuel package requires a newer
# version of Rust, we should specify the necessary condition in a new patch
# to ensure only newer packages use the newer version of Rust.
{
condition = m: true;
patch = m: {
cargoLock.lockFile = "${m.src}/Cargo.lock";
meta.homepage = m.src.gitRepoUrl;
rust = pkgs.rust-bin.stable."1.63.0".default;
};
}
# Packages within the sway and fuel-core repos are normally defined within a
# subdirectory that is equal to their package name.
{
condition = m:
pkgs.lib.any (url: m.src.gitRepoUrl == url) [
"https://github.com/fuellabs/sway"
"https://github.com/fuellabs/fuel-core"
];
patch = m: {
buildAndTestSubdir = m.pname;
};
}
# From around version 0.19.0 until roughly 2022-09-08, the Sway repo had a
# workspace-level patch for `mdbook` that pointed to a git repo. This patch
# provides that git repo's output hash to ensure deterministic builds for
# commits within that range.
{
condition = m:
m.src.gitRepoUrl
== "https://github.com/fuellabs/sway"
&& pkgs.lib.versionAtLeast m.version "0.19.0"
&& (m.date <= "2022-09-08" || m.src.rev == "19b9fecdba613a229b7b3c3db7fe86113aefb2fe");
patch = m: {
cargoLock.outputHashes = {
"mdbook-0.4.20" = "sha256-hNyG2DVD1KFttXF4m8WnfoxRjA0cghA7NoV5AW7wZrI=";
};
meta.license = pkgs.lib.licenses.asl20;
};
}
# The fuel-core crate requires clang for the rocksdb bindings generation.
# We also specify `ROCKSDB_LIB_DIR` in order to allow the rocksdb build
# script to use rocksdb as a dynamic library.
{
condition = m: m.pname == "fuel-core";
patch = m: {
nativeBuildInputs = (m.nativeBuildInputs or []) ++ [pkgs.clang];
buildInputs = (m.buildInputs or []) ++ [pkgs.rocksdb];
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
};
}
# Fuel-core tests run at their repo - no need to repeat them here.
{
condition = m: m.src.gitRepoUrl == "https://github.com/fuellabs/fuel-core";
patch = m: {
doCheck = false; # Already tested at repo, causes longer build times.
};
}
# The `fuel-gql-cli`'s fuel-core subdirectory does not match its binary name,
# so we specify the correct subdirectory here.
{
condition = m: m.pname == "fuel-gql-cli";
patch = m: {
buildAndTestSubdir = "fuel-client";
};
}
# Some `forc-pkg` and some crates that depend on it require openssl, so add
# the required packages.
{
condition = m: pkgs.lib.any (n: m.pname == n) (["forc"] ++ forc-plugins);
patch = m: {
nativeBuildInputs =
(m.nativeBuildInputs or [])
++ [
pkgs.perl # for openssl-sys
pkgs.pkg-config # for openssl-sys
];
};
}
# The forc plugins that reside in the Sway repo are in a dedicated
# subdirectory.
{
condition = m: pkgs.lib.any (n: m.pname == n) forc-plugins;
patch = m: {
buildAndTestSubdir = "forc-plugins/${m.pname}";
};
}
# A patch for some `forc-wallet` nightlies whose committed `Cargo.lock` file
# was out of date.
{
condition = m: m.pname == "forc-wallet" && m.version == "0.1.0" && m.date < "2022-09-04";
patch = m: {
cargoPatches = [
./patch/forc-wallet-0.1.0-update-lock.patch
];
cargoHash = "sha256-LXQaPcpf/n1RRFTQXAP6PexfEI67U2Z5OOW5DzNJvX8=";
cargoLock = null;
};
}
# A patch for a `fuel-core` and `fuel-gql-cli` nightly whose committed
# `Cargo.lock` file was out of date.
{
condition = m: m.src.gitRepoUrl == "https://github.com/fuellabs/fuel-core" && m.version == "0.10.1" && m.date == "2022-09-07";
patch = m: {
cargoPatches = [
./patch/fuel-core-0.10.1-nightly-2022-09-08-update-lock.patch
];
cargoHash =
if m.pname == "fuel-core"
then "sha256-WyGQWKLVtk+z0mahfve/0SyEW4u1oo3xQOUCYi9CKWM="
else "sha256-xxFA97O1RX1rR9LGvU7z/4r/8b/VmeMksaoRYTgXcPo=";
cargoLock = null;
};
}
# We generally appear to require these frameworks on darwin.
{
condition = m: pkgs.lib.hasInfix "darwin" pkgs.system;
patch = m: {
buildInputs =
(m.buildInputs or [])
++ [
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
};
}
# Attempt at solving this:
# https://github.com/mitchmindtree/fuel.nix/pull/17#issuecomment-1254844214
{
condition = m: pkgs.lib.hasInfix "darwin" pkgs.system && m.pname == "fuel-core";
patch = m: {
NIX_CFLAGS_COMPILE = pkgs.lib.optionalString pkgs.stdenv.cc.isClang "-Wno-error=unused-private-field -faligned-allocation";
};
}
# `fuel-core` needs Rust 1.64 as of bcb86da09b6fdce09f13ef4181a0ca6461f8e2a8.
# This changes the Rust used for all pkgs to 1.64 from the day of the commit.
{
condition = m: m.date >= "2022-09-23";
patch = m: {
rust = pkgs.rust-bin.stable."1.64.0".default;
};
}
# Since this date, `forc-wallet` got some tests that require doing file
# operations that are unpermitted in Nix's sandbox during a build. These
# tests are run at `forc-wallet`'s repo CI, so it's fine to disable the check
# here.
{
condition = m: m.pname == "forc-wallet" && m.date >= "2022-10-10";
patch = m: {
doCheck = false; # Already tested at repo.
};
}
# At some point around this date, Sway LSP started requiring the CoreServices
# framework on Darwin due to a dependency update. Here we just make it
# available to all fuel packages going forward.
{
condition = m: pkgs.lib.hasInfix "darwin" pkgs.system && m.date >= "2022-10-10";
patch = m: {
buildInputs =
(m.buildInputs or [])
++ [
pkgs.darwin.apple_sdk.frameworks.CoreServices
];
};
}
# Since this date, `forc` got some tests that require doing file operations
# that are unpermitted in Nix's sandbox during a build. These tests are run
# at `forc`'s repo CI, so it's fine to disable the check here.
{
condition = m: pkgs.lib.any (n: m.pname == n) (["forc"] ++ forc-plugins) && m.date >= "2022-10-31";
patch = m: {
doCheck = false; # Already tested at repo.
};
}
# As of 2022-12-17 the fuel-core exe was moved into the `bin` subdirectory.
# Version 0.15.3 (rev 49e4305fea691bbf293c606334e7b282a54393b3) retains the
# old directory structure.
{
condition = m:
m.pname
== "fuel-core"
&& m.date >= "2022-12-17"
&& m.src.rev != "49e4305fea691bbf293c606334e7b282a54393b3";
patch = m: {
buildAndTestSubdir = "bin/fuel-core";
};
}
# As of 2022-12-17 the fuel-core-client exe was renamed and moved into the `bin`
# subdirectory.
# Version 0.15.3 (rev 49e4305fea691bbf293c606334e7b282a54393b3) retains the
# old directory structure.
{
condition = m: m.pname == "fuel-core-client";
patch = m: {
buildAndTestSubdir =
if m.src.rev == "49e4305fea691bbf293c606334e7b282a54393b3"
then "fuel-client"
else "bin/fuel-core-client";
};
}
# For a short while around version 0.33.0 (roughly 2023-01-14 to 2023-01-18),
# the Sway repo had a git dependency on the ethabi-18.0.0 crate. This was
# removed in favour of using our own crate.
{
condition = m:
m.src.gitRepoUrl
== "https://github.com/fuellabs/sway"
&& pkgs.lib.versionAtLeast m.version "0.33.0"
&& (m.date >= "2023-01-14" || m.src.rev == "a0be5f2cbe0bf7a6d008a2210920da9d4ff5dbae")
&& m.date < "2023-01-18";
patch = m: {
cargoLock.outputHashes =
(m.cargoLock.outputHashes or {})
// {
"ethabi-18.0.0" = "sha256-N5bjuJoGYzcnfQg5pe79joUI2gOPAd9tcSvrBOYv5rc=";
};
};
}
# `fuel-storage` needs Rust 1.65 as of
# cc11d3184c78401436d984e660748c9a9ed3df88 due to its use of generic
# associated types. This changes the Rust used for all pkgs to 1.65 from the
# day of the commit.
{
condition = m: m.date >= "2023-01-13";
patch = m: {
rust = pkgs.rust-bin.stable."1.65.0".default;
};
}
# `fuel-core` crates need Rust 1.67 as of
# `580b2212bd5fa9870c9fef11e0ad72f373925e78` due to use of `checked_ilog` in
# `fuel-vm` 0.25.3.
{
condition = m: m.date >= "2023-02-03" || m.src.rev == "580b2212bd5fa9870c9fef11e0ad72f373925e78";
patch = m: {
rust = pkgs.rust-bin.stable."1.67.0".default;
};
}
# `forc-client` requires Rust 1.68 as of 0.40.1.
{
condition = m: m.date >= "2023-05-30";
patch = m: {
rust = pkgs.rust-bin.stable."1.68.0".default;
};
}
# `forc` requires Rust 1.70 as of ~2023-07-01
{
condition = m: m.date >= "2023-07-01";
patch = m: {
rust = pkgs.rust-bin.stable."1.70.0".default;
};
}
# `fuel-tx` requires Rust 1.73 as of ~2023-11-15 due to use of `div_ceil`.
{
condition = m: m.date >= "2023-11-15";
patch = m: {
rust = pkgs.rust-bin.stable."1.73.0".default;
};
}
# `forc-client` requires Rust 1.74 as of
# 3fcb76cfb2ad4e4d1987f7f978aa594fd0ce02c5 due to use of `fuels-core v0.54.0`.
{
condition = m: m.date >= "2024-01-04";
patch = m: {
rust = pkgs.rust-bin.stable."1.74.0".default;
};
}
# `sway-core` requires Rust 1.76 as of
# c18797fd04f210d6f2f25415536685e63cbd1cc5 due to use of `std::hash::DefaultHasher`.
{
condition = m: m.date >= "2024-03-11";
patch = m: {
rust = pkgs.rust-bin.stable."1.76.0".default;
};
}
# `fuel-core-client` requires wasm32-unknown-unknown target to be added as of ~2024-04-01.
{
condition = m: m.date >= "2024-04-13";
patch = m: {
rust = pkgs.rust-bin.stable."1.76.0".default.override {
targets = ["wasm32-unknown-unknown"];
};
};
}
# `fuels-rs` requires Rust 1.79 as of v0.66.0 due to the use of `path::absolute`.
{
condition = m: m.date >= "2024-08-08";
patch = m: {
rust = pkgs.rust-bin.stable."1.79.0".default.override {
targets = ["wasm32-unknown-unknown"];
};
};
}
]