Skip to content

Commit 6f928c4

Browse files
chore(nix): nix package (#106)
1 parent e510182 commit 6f928c4

File tree

16 files changed

+1601
-130
lines changed

16 files changed

+1601
-130
lines changed

apps/engine/deps.nix

Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
{
2+
pkgs,
3+
lib,
4+
beamPackages,
5+
overrides ? (x: y: { }),
6+
overrideFenixOverlay ? null,
7+
}:
8+
9+
let
10+
buildMix = lib.makeOverridable beamPackages.buildMix;
11+
buildRebar3 = lib.makeOverridable beamPackages.buildRebar3;
12+
13+
workarounds = {
14+
portCompiler = _unusedArgs: old: {
15+
buildPlugins = [ pkgs.beamPackages.pc ];
16+
};
17+
18+
rustlerPrecompiled =
19+
{
20+
toolchain ? null,
21+
...
22+
}:
23+
old:
24+
let
25+
extendedPkgs = pkgs.extend fenixOverlay;
26+
fenixOverlay =
27+
if overrideFenixOverlay == null then
28+
import "${
29+
fetchTarball {
30+
url = "https://github.com/nix-community/fenix/archive/056c9393c821a4df356df6ce7f14c722dc8717ec.tar.gz";
31+
sha256 = "sha256:1cdfh6nj81gjmn689snigidyq7w98gd8hkl5rvhly6xj7vyppmnd";
32+
}
33+
}/overlay.nix"
34+
else
35+
overrideFenixOverlay;
36+
nativeDir = "${old.src}/native/${with builtins; head (attrNames (readDir "${old.src}/native"))}";
37+
fenix =
38+
if toolchain == null then
39+
extendedPkgs.fenix.stable
40+
else
41+
extendedPkgs.fenix.fromToolchainName toolchain;
42+
native =
43+
(extendedPkgs.makeRustPlatform {
44+
inherit (fenix) cargo rustc;
45+
}).buildRustPackage
46+
{
47+
pname = "${old.packageName}-native";
48+
version = old.version;
49+
src = nativeDir;
50+
cargoLock = {
51+
lockFile = "${nativeDir}/Cargo.lock";
52+
};
53+
nativeBuildInputs = [
54+
extendedPkgs.cmake
55+
];
56+
doCheck = false;
57+
};
58+
59+
in
60+
{
61+
nativeBuildInputs = [ extendedPkgs.cargo ];
62+
63+
env.RUSTLER_PRECOMPILED_FORCE_BUILD_ALL = "true";
64+
env.RUSTLER_PRECOMPILED_GLOBAL_CACHE_PATH = "unused-but-required";
65+
66+
preConfigure = ''
67+
mkdir -p priv/native
68+
for lib in ${native}/lib/*
69+
do
70+
ln -s "$lib" "priv/native/$(basename "$lib")"
71+
done
72+
'';
73+
74+
buildPhase = ''
75+
suggestion() {
76+
echo "***********************************************"
77+
echo " deps_nix "
78+
echo
79+
echo " Rust dependency build failed. "
80+
echo
81+
echo " If you saw network errors, you might need "
82+
echo " to disable compilation on the appropriate "
83+
echo " RustlerPrecompiled module in your "
84+
echo " application config. "
85+
echo
86+
echo " We think you need this: "
87+
echo
88+
echo -n " "
89+
grep -Rl 'use RustlerPrecompiled' lib \
90+
| xargs grep 'defmodule' \
91+
| sed 's/defmodule \(.*\) do/config :${old.packageName}, \1, skip_compilation?: true/'
92+
echo "***********************************************"
93+
exit 1
94+
}
95+
trap suggestion ERR
96+
${old.buildPhase}
97+
'';
98+
};
99+
};
100+
101+
defaultOverrides = (
102+
final: prev:
103+
104+
let
105+
apps = {
106+
crc32cer = [
107+
{
108+
name = "portCompiler";
109+
}
110+
];
111+
explorer = [
112+
{
113+
name = "rustlerPrecompiled";
114+
toolchain = {
115+
name = "nightly-2024-11-01";
116+
sha256 = "sha256-wq7bZ1/IlmmLkSa3GUJgK17dTWcKyf5A+ndS9yRwB88=";
117+
};
118+
}
119+
];
120+
snappyer = [
121+
{
122+
name = "portCompiler";
123+
}
124+
];
125+
};
126+
127+
applyOverrides =
128+
appName: drv:
129+
let
130+
allOverridesForApp = builtins.foldl' (
131+
acc: workaround: acc // (workarounds.${workaround.name} workaround) drv
132+
) { } apps.${appName};
133+
134+
in
135+
if builtins.hasAttr appName apps then drv.override allOverridesForApp else drv;
136+
137+
in
138+
builtins.mapAttrs applyOverrides prev
139+
);
140+
141+
self = packages // (defaultOverrides self packages) // (overrides self packages);
142+
143+
packages =
144+
with beamPackages;
145+
with self;
146+
{
147+
148+
elixir_sense =
149+
let
150+
version = "e3ddc403554050221a2fd19a10a896fa7525bc02";
151+
drv = buildMix {
152+
inherit version;
153+
name = "elixir_sense";
154+
appConfigPath = ./config;
155+
156+
src = pkgs.fetchFromGitHub {
157+
owner = "elixir-lsp";
158+
repo = "elixir_sense";
159+
rev = "e3ddc403554050221a2fd19a10a896fa7525bc02";
160+
hash = "sha256-Rs/c6uduC2xauSwO7FGEVYWiyhNbhSsIcw5s04d+A8M=";
161+
};
162+
};
163+
in
164+
drv;
165+
166+
gen_lsp =
167+
let
168+
version = "0.11.0";
169+
drv = buildMix {
170+
inherit version;
171+
name = "gen_lsp";
172+
appConfigPath = ./config;
173+
174+
src = fetchHex {
175+
inherit version;
176+
pkg = "gen_lsp";
177+
sha256 = "d67c20650a5290a02f7bac53083ac4487d3c6b461f35a8b14c5d2d7638c20d26";
178+
};
179+
180+
beamDeps = [
181+
jason
182+
nimble_options
183+
schematic
184+
typed_struct
185+
];
186+
};
187+
in
188+
drv;
189+
190+
jason =
191+
let
192+
version = "1.4.4";
193+
drv = buildMix {
194+
inherit version;
195+
name = "jason";
196+
appConfigPath = ./config;
197+
198+
src = fetchHex {
199+
inherit version;
200+
pkg = "jason";
201+
sha256 = "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b";
202+
};
203+
};
204+
in
205+
drv;
206+
207+
nimble_options =
208+
let
209+
version = "1.1.1";
210+
drv = buildMix {
211+
inherit version;
212+
name = "nimble_options";
213+
appConfigPath = ./config;
214+
215+
src = fetchHex {
216+
inherit version;
217+
pkg = "nimble_options";
218+
sha256 = "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44";
219+
};
220+
};
221+
in
222+
drv;
223+
224+
nimble_parsec =
225+
let
226+
version = "1.2.3";
227+
drv = buildMix {
228+
inherit version;
229+
name = "nimble_parsec";
230+
appConfigPath = ./config;
231+
232+
src = fetchHex {
233+
inherit version;
234+
pkg = "nimble_parsec";
235+
sha256 = "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0";
236+
};
237+
};
238+
in
239+
drv;
240+
241+
path_glob =
242+
let
243+
version = "0.2.0";
244+
drv = buildMix {
245+
inherit version;
246+
name = "path_glob";
247+
appConfigPath = ./config;
248+
249+
src = fetchHex {
250+
inherit version;
251+
pkg = "path_glob";
252+
sha256 = "be2594cb4553169a1a189f95193d910115f64f15f0d689454bb4e8cfae2e7ebc";
253+
};
254+
255+
beamDeps = [
256+
nimble_parsec
257+
];
258+
};
259+
in
260+
drv;
261+
262+
refactorex =
263+
let
264+
version = "0.1.52";
265+
drv = buildMix {
266+
inherit version;
267+
name = "refactorex";
268+
appConfigPath = ./config;
269+
270+
src = fetchHex {
271+
inherit version;
272+
pkg = "refactorex";
273+
sha256 = "4927fe6c3acd1f4695d6d3e443380167d61d004d507b1279c6084433900c94d0";
274+
};
275+
276+
beamDeps = [
277+
sourceror
278+
];
279+
};
280+
in
281+
drv;
282+
283+
schematic =
284+
let
285+
version = "0.2.1";
286+
drv = buildMix {
287+
inherit version;
288+
name = "schematic";
289+
appConfigPath = ./config;
290+
291+
src = fetchHex {
292+
inherit version;
293+
pkg = "schematic";
294+
sha256 = "0b255d65921e38006138201cd4263fd8bb807d9dfc511074615cd264a571b3b1";
295+
};
296+
297+
beamDeps = [
298+
telemetry
299+
];
300+
};
301+
in
302+
drv;
303+
304+
snowflake =
305+
let
306+
version = "1.0.4";
307+
drv = buildMix {
308+
inherit version;
309+
name = "snowflake";
310+
appConfigPath = ./config;
311+
312+
src = fetchHex {
313+
inherit version;
314+
pkg = "snowflake";
315+
sha256 = "badb07ebb089a5cff737738297513db3962760b10fe2b158ae3bebf0b4d5be13";
316+
};
317+
};
318+
in
319+
drv;
320+
321+
sourceror =
322+
let
323+
version = "1.10.0";
324+
drv = buildMix {
325+
inherit version;
326+
name = "sourceror";
327+
appConfigPath = ./config;
328+
329+
src = fetchHex {
330+
inherit version;
331+
pkg = "sourceror";
332+
sha256 = "29dbdfc92e04569c9d8e6efdc422fc1d815f4bd0055dc7c51b8800fb75c4b3f1";
333+
};
334+
};
335+
in
336+
drv;
337+
338+
telemetry =
339+
let
340+
version = "1.3.0";
341+
drv = buildRebar3 {
342+
inherit version;
343+
name = "telemetry";
344+
345+
src = fetchHex {
346+
inherit version;
347+
pkg = "telemetry";
348+
sha256 = "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6";
349+
};
350+
};
351+
in
352+
drv;
353+
354+
typed_struct =
355+
let
356+
version = "0.3.0";
357+
drv = buildMix {
358+
inherit version;
359+
name = "typed_struct";
360+
appConfigPath = ./config;
361+
362+
src = fetchHex {
363+
inherit version;
364+
pkg = "typed_struct";
365+
sha256 = "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d";
366+
};
367+
};
368+
in
369+
drv;
370+
371+
};
372+
in
373+
self

apps/engine/mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ defmodule Engine.MixProject do
4545
defp deps do
4646
[
4747
{:benchee, "~> 1.3", only: :test},
48+
{:deps_nix, "~> 2.4", only: :dev},
4849
Mix.Credo.dependency(),
4950
Mix.Dialyzer.dependency(),
5051
{:elixir_sense,

apps/engine/mix.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
"castore": {:hex, :castore, "1.0.12", "053f0e32700cbec356280c0e835df425a3be4bc1e0627b714330ad9d0f05497f", [:mix], [], "hexpm", "3dca286b2186055ba0c9449b4e95b97bf1b57b47c1f2644555879e659960c224"},
55
"credo": {:hex, :credo, "1.7.12", "9e3c20463de4b5f3f23721527fcaf16722ec815e70ff6c60b86412c695d426c1", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8493d45c656c5427d9c729235b99d498bd133421f3e0a683e5c1b561471291e5"},
66
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
7+
"deps_nix": {:hex, :deps_nix, "2.4.0", "2be1ee54b25f7048e8974810a1dca2f1ff3d62ffaac64d83ef1f0d62e64c7cb4", [:mix], [{:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: false]}], "hexpm", "0f953f79b716d8627fd5a301615f1364d753e6c22e1380cdbd6a32f9e972370d"},
78
"dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"},
89
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "e3ddc403554050221a2fd19a10a896fa7525bc02", [ref: "e3ddc403554050221a2fd19a10a896fa7525bc02"]},
910
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
1011
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
1112
"gen_lsp": {:hex, :gen_lsp, "0.11.0", "9eda4d2fcaff94d9b3062e322fcf524c176db1502f584a3cff6135088b46084b", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "d67c20650a5290a02f7bac53083ac4487d3c6b461f35a8b14c5d2d7638c20d26"},
13+
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
1214
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1315
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
16+
"mint": {:hex, :mint, "1.7.1", "113fdb2b2f3b59e47c7955971854641c61f378549d73e829e1768de90fc1abf1", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "fceba0a4d0f24301ddee3024ae116df1c3f4bb7a563a731f45fdfeb9d39a231b"},
1417
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
1518
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
1619
"patch": {:hex, :patch, "0.15.0", "947dd6a8b24a2d2d1137721f20bb96a8feb4f83248e7b4ad88b4871d52807af5", [:mix], [], "hexpm", "e8dadf9b57b30e92f6b2b1ce2f7f57700d14c66d4ed56ee27777eb73fb77e58d"},

0 commit comments

Comments
 (0)