From 17c41dbc33a395f654194bdc956b9eabbddb12f4 Mon Sep 17 00:00:00 2001 From: Juozas Norkus Date: Fri, 29 Sep 2023 16:58:04 +0300 Subject: [PATCH] fix: nix build (#247) --- flake.lock | 6 +++--- flake.nix | 6 +++++- mix.exs | 19 +++++++++++++++++-- mix.lock | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index 17d72b54..3d7a621b 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1693535723, - "narHash": "sha256-ERFGB4HsvW4MASfaiYa5KDpaMc6US4FgK5KAYROCsbg=", + "lastModified": 1695669266, + "narHash": "sha256-QrCnbAcP9DtchKYaEC5LMpOBlpp2gBxua2626g3W41Q=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "76ae447f06e8be22c1adba3d979bcf5a3b7b14b9", + "rev": "7e5e43ef91a3828f92f8dd149d9af6521d0c736b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c7268a3b..66ddc94a 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,7 @@ mixFodDeps = beamPackages.fetchMixDeps { inherit src version; pname = "${pname}-deps"; - hash = "sha256-jUkz/pu3iyizpHkMYgmbYfalFv10t11b6SmLVEXAJ30="; + hash = "sha256-sRve0L7qFw5vEsespIXVg4loSej+oLO1ewdmT6qGExw="; }; preConfigure = '' @@ -73,6 +73,10 @@ export PATH="$bindir:$PATH" ''; + preBuild = '' + export BURRITO_ERTS_PATH=${beamPackages.erlang}/lib/erlang + ''; + preInstall = if type == "local" then '' export BURRITO_TARGET="${burritoExe(system)}" diff --git a/mix.exs b/mix.exs index e7a65cad..2f4883ae 100644 --- a/mix.exs +++ b/mix.exs @@ -40,7 +40,7 @@ defmodule NextLS.MixProject do next_ls: [ steps: [:assemble, &Burrito.wrap/1], burrito: [ - targets: [ + targets: inject_custom_erts([ darwin_arm64: [os: :darwin, cpu: :aarch64], darwin_amd64: [os: :darwin, cpu: :x86_64], linux_arm64: [os: :linux, cpu: :aarch64, libc: :gnu], @@ -48,7 +48,7 @@ defmodule NextLS.MixProject do linux_arm64_musl: [os: :linux, cpu: :aarch64, libc: :musl], linux_amd64_musl: [os: :linux, cpu: :x86_64, libc: :musl], windows_amd64: [os: :windows, cpu: :x86_64] - ] + ]) ] ] ] @@ -84,4 +84,19 @@ defmodule NextLS.MixProject do files: ~w(lib LICENSE mix.exs priv README.md .formatter.exs) ] end + + defp inject_custom_erts(targets) do + # By default, Burrito downloads ERTS from https://burrito-otp.b-cdn.net. + # When building with Nix, side-effects like network access are not allowed, + # so we need to inject our own ERTS path. + + erts_path = System.get_env("BURRITO_ERTS_PATH", "") + + Enum.map(targets, fn {target_name, target_conf} -> + case erts_path do + "" -> {target_name, target_conf} + path -> {target_name, [{:custom_erts, path} | target_conf]} + end + end) + end end diff --git a/mix.lock b/mix.lock index 044c3ee9..7b1a1f58 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,5 @@ %{ - "burrito": {:git, "https://github.com/burrito-elixir/burrito.git", "5c7b29811279f3272005534a3fec29a687e9b6bf", []}, + "burrito": {:git, "https://github.com/burrito-elixir/burrito.git", "a86857636eaba9a7fa179fd970ed6cf82e9e7d59", []}, "bypass": {:hex, :bypass, "2.1.0", "909782781bf8e20ee86a9cabde36b259d44af8b9f38756173e8f5e2e1fabb9b1", [:mix], [{:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "d9b5df8fa5b7a6efa08384e9bbecfe4ce61c77d28a4282f79e02f1ef78d96b80"}, "castore": {:hex, :castore, "1.0.3", "7130ba6d24c8424014194676d608cb989f62ef8039efd50ff4b3f33286d06db8", [:mix], [], "hexpm", "680ab01ef5d15b161ed6a95449fac5c6b8f60055677a8e79acf01b27baa4390b"}, "cc_precompiler": {:hex, :cc_precompiler, "0.1.8", "933a5f4da3b19ee56539a076076ce4d7716d64efc8db46fd066996a7e46e2bfd", [:mix], [{:elixir_make, "~> 0.7.3", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "176bdf4366956e456bf761b54ad70bc4103d0269ca9558fd7cee93d1b3f116db"},