git.iko.soy/typeable/nixpkgs
on master help sign in
rebar3Relx: add beamDeps support
commit72795f8c0bdd7ca578fa051f1ade79a47f620f77 authorDavid <dlesl@users.noreply.github.com> dateMon 17 May 2021, 17:51 (6 years ago) parentac9b645
1 file changed+28−13
pkgs/development/beam-modules/rebar3-release.nix+28−13
pkgs/development/beam-modules/rebar3-release.nix+28−13
@@ -1,8 +1,10 @@
1−{ stdenv, writeText, erlang, rebar3, openssl,
1+{ stdenv, erlang, rebar3WithPlugins, openssl,
22 lib }:
33
44{ name, version
55, src
6+, beamDeps ? []
7+, buildPlugins ? []
68, checkouts ? null
79, releaseType
810, buildInputs ? []
@@ -12,7 +14,6 @@
1214, buildPhase ? null
1315, configurePhase ? null
1416, meta ? {}
15−, enableDebugInfo ? false
1617, ... }@attrs:
1718
1819with lib;
@@ -27,28 +28,42 @@ let
2728 (_: v: v != null)
2829 { inherit setupHook configurePhase buildPhase installPhase; };
2930
30− pkg = self: stdenv.mkDerivation (attrs // {
31+ # When using the `beamDeps` argument, it is important that we use
32+ # `rebar3WithPlugins` here even when there are no plugins. The vanilla
33+ # `rebar3` package is an escript archive with bundled dependencies which can
34+ # interfere with those in the app we are trying to build. `rebar3WithPlugins`
35+ # doesn't have this issue since it puts its own deps last on the code path.
36+ rebar3 = rebar3WithPlugins {
37+ plugins = buildPlugins;
38+ };
39+
40+ pkg =
41+ assert beamDeps != [] -> checkouts == null;
42+ self: stdenv.mkDerivation (attrs // {
3143
3244 name = "${name}-${version}";
3345 inherit version;
3446
35− buildInputs = buildInputs ++ [ erlang rebar3 openssl ];
36− propagatedBuildInputs = [checkouts];
47+ buildInputs = buildInputs ++ [ erlang rebar3 openssl ] ++ beamDeps;
3748
3849 dontStrip = true;
3950
4051 inherit src;
4152
42− setupHook = writeText "setupHook.sh" ''
43− addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
44− '';
45−
4653 configurePhase = ''
4754 runHook preConfigure
48− ${if checkouts != null then
49− "cp --no-preserve=all -R ${checkouts}/_checkouts ."
50− else
51− ""}
55+ ${lib.optionalString (checkouts != null)
56+ "cp --no-preserve=all -R ${checkouts}/_checkouts ."}
57+ ${# Prevent rebar3 from trying to manage deps
58+ lib.optionalString (beamDeps != [ ]) ''
59+ erl -noshell -eval '
60+ {ok, Terms0} = file:consult("rebar.config"),
61+ Terms = lists:keydelete(deps, 1, Terms0),
62+ ok = file:write_file("rebar.config", [io_lib:format("~tp.~n", [T]) || T <- Terms]),
63+ init:stop(0)
64+ '
65+ rm -f rebar.lock
66+ ''}
5267 runHook postConfigure
5368 '';
5469