Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
373 changes: 373 additions & 0 deletions apps/engine/deps.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,373 @@
{
pkgs,
lib,
beamPackages,
overrides ? (x: y: { }),
overrideFenixOverlay ? null,
}:

let
buildMix = lib.makeOverridable beamPackages.buildMix;
buildRebar3 = lib.makeOverridable beamPackages.buildRebar3;

workarounds = {
portCompiler = _unusedArgs: old: {
buildPlugins = [ pkgs.beamPackages.pc ];
};

rustlerPrecompiled =
{
toolchain ? null,
...
}:
old:
let
extendedPkgs = pkgs.extend fenixOverlay;
fenixOverlay =
if overrideFenixOverlay == null then
import "${
fetchTarball {
url = "https://github.com/nix-community/fenix/archive/056c9393c821a4df356df6ce7f14c722dc8717ec.tar.gz";
sha256 = "sha256:1cdfh6nj81gjmn689snigidyq7w98gd8hkl5rvhly6xj7vyppmnd";
}
}/overlay.nix"
else
overrideFenixOverlay;
nativeDir = "${old.src}/native/${with builtins; head (attrNames (readDir "${old.src}/native"))}";
fenix =
if toolchain == null then
extendedPkgs.fenix.stable
else
extendedPkgs.fenix.fromToolchainName toolchain;
native =
(extendedPkgs.makeRustPlatform {
inherit (fenix) cargo rustc;
}).buildRustPackage
{
pname = "${old.packageName}-native";
version = old.version;
src = nativeDir;
cargoLock = {
lockFile = "${nativeDir}/Cargo.lock";
};
nativeBuildInputs = [
extendedPkgs.cmake
];
doCheck = false;
};

in
{
nativeBuildInputs = [ extendedPkgs.cargo ];

env.RUSTLER_PRECOMPILED_FORCE_BUILD_ALL = "true";
env.RUSTLER_PRECOMPILED_GLOBAL_CACHE_PATH = "unused-but-required";

preConfigure = ''
mkdir -p priv/native
for lib in ${native}/lib/*
do
ln -s "$lib" "priv/native/$(basename "$lib")"
done
'';

buildPhase = ''
suggestion() {
echo "***********************************************"
echo " deps_nix "
echo
echo " Rust dependency build failed. "
echo
echo " If you saw network errors, you might need "
echo " to disable compilation on the appropriate "
echo " RustlerPrecompiled module in your "
echo " application config. "
echo
echo " We think you need this: "
echo
echo -n " "
grep -Rl 'use RustlerPrecompiled' lib \
| xargs grep 'defmodule' \
| sed 's/defmodule \(.*\) do/config :${old.packageName}, \1, skip_compilation?: true/'
echo "***********************************************"
exit 1
}
trap suggestion ERR
${old.buildPhase}
'';
};
};

defaultOverrides = (
final: prev:

let
apps = {
crc32cer = [
{
name = "portCompiler";
}
];
explorer = [
{
name = "rustlerPrecompiled";
toolchain = {
name = "nightly-2024-11-01";
sha256 = "sha256-wq7bZ1/IlmmLkSa3GUJgK17dTWcKyf5A+ndS9yRwB88=";
};
}
];
snappyer = [
{
name = "portCompiler";
}
];
};

applyOverrides =
appName: drv:
let
allOverridesForApp = builtins.foldl' (
acc: workaround: acc // (workarounds.${workaround.name} workaround) drv
) { } apps.${appName};

in
if builtins.hasAttr appName apps then drv.override allOverridesForApp else drv;

in
builtins.mapAttrs applyOverrides prev
);

self = packages // (defaultOverrides self packages) // (overrides self packages);

packages =
with beamPackages;
with self;
{

elixir_sense =
let
version = "e3ddc403554050221a2fd19a10a896fa7525bc02";
drv = buildMix {
inherit version;
name = "elixir_sense";
appConfigPath = ./config;

src = pkgs.fetchFromGitHub {
owner = "elixir-lsp";
repo = "elixir_sense";
rev = "e3ddc403554050221a2fd19a10a896fa7525bc02";
hash = "sha256-Rs/c6uduC2xauSwO7FGEVYWiyhNbhSsIcw5s04d+A8M=";
};
};
in
drv;

gen_lsp =
let
version = "0.11.0";
drv = buildMix {
inherit version;
name = "gen_lsp";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "gen_lsp";
sha256 = "d67c20650a5290a02f7bac53083ac4487d3c6b461f35a8b14c5d2d7638c20d26";
};

beamDeps = [
jason
nimble_options
schematic
typed_struct
];
};
in
drv;

jason =
let
version = "1.4.4";
drv = buildMix {
inherit version;
name = "jason";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "jason";
sha256 = "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b";
};
};
in
drv;

nimble_options =
let
version = "1.1.1";
drv = buildMix {
inherit version;
name = "nimble_options";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "nimble_options";
sha256 = "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44";
};
};
in
drv;

nimble_parsec =
let
version = "1.2.3";
drv = buildMix {
inherit version;
name = "nimble_parsec";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "nimble_parsec";
sha256 = "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0";
};
};
in
drv;

path_glob =
let
version = "0.2.0";
drv = buildMix {
inherit version;
name = "path_glob";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "path_glob";
sha256 = "be2594cb4553169a1a189f95193d910115f64f15f0d689454bb4e8cfae2e7ebc";
};

beamDeps = [
nimble_parsec
];
};
in
drv;

refactorex =
let
version = "0.1.52";
drv = buildMix {
inherit version;
name = "refactorex";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "refactorex";
sha256 = "4927fe6c3acd1f4695d6d3e443380167d61d004d507b1279c6084433900c94d0";
};

beamDeps = [
sourceror
];
};
in
drv;

schematic =
let
version = "0.2.1";
drv = buildMix {
inherit version;
name = "schematic";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "schematic";
sha256 = "0b255d65921e38006138201cd4263fd8bb807d9dfc511074615cd264a571b3b1";
};

beamDeps = [
telemetry
];
};
in
drv;

snowflake =
let
version = "1.0.4";
drv = buildMix {
inherit version;
name = "snowflake";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "snowflake";
sha256 = "badb07ebb089a5cff737738297513db3962760b10fe2b158ae3bebf0b4d5be13";
};
};
in
drv;

sourceror =
let
version = "1.10.0";
drv = buildMix {
inherit version;
name = "sourceror";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "sourceror";
sha256 = "29dbdfc92e04569c9d8e6efdc422fc1d815f4bd0055dc7c51b8800fb75c4b3f1";
};
};
in
drv;

telemetry =
let
version = "1.3.0";
drv = buildRebar3 {
inherit version;
name = "telemetry";

src = fetchHex {
inherit version;
pkg = "telemetry";
sha256 = "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6";
};
};
in
drv;

typed_struct =
let
version = "0.3.0";
drv = buildMix {
inherit version;
name = "typed_struct";
appConfigPath = ./config;

src = fetchHex {
inherit version;
pkg = "typed_struct";
sha256 = "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d";
};
};
in
drv;

};
in
self
1 change: 1 addition & 0 deletions apps/engine/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ defmodule Engine.MixProject do
defp deps do
[
{:benchee, "~> 1.3", only: :test},
{:deps_nix, "~> 2.4", only: :dev},
Mix.Credo.dependency(),
Mix.Dialyzer.dependency(),
{:elixir_sense,
Expand Down
3 changes: 3 additions & 0 deletions apps/engine/mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"castore": {:hex, :castore, "1.0.12", "053f0e32700cbec356280c0e835df425a3be4bc1e0627b714330ad9d0f05497f", [:mix], [], "hexpm", "3dca286b2186055ba0c9449b4e95b97bf1b57b47c1f2644555879e659960c224"},
"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"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"deps_nix": {:hex, :deps_nix, "2.4.0", "2be1ee54b25f7048e8974810a1dca2f1ff3d62ffaac64d83ef1f0d62e64c7cb4", [:mix], [{:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: false]}], "hexpm", "0f953f79b716d8627fd5a301615f1364d753e6c22e1380cdbd6a32f9e972370d"},
"dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"},
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "e3ddc403554050221a2fd19a10a896fa7525bc02", [ref: "e3ddc403554050221a2fd19a10a896fa7525bc02"]},
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
"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"},
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
"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"},
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
"patch": {:hex, :patch, "0.15.0", "947dd6a8b24a2d2d1137721f20bb96a8feb4f83248e7b4ad88b4871d52807af5", [:mix], [], "hexpm", "e8dadf9b57b30e92f6b2b1ce2f7f57700d14c66d4ed56ee27777eb73fb77e58d"},
Expand Down
Loading