rebar3Relx: add beamDeps support
This commit is contained in:
parent
ac9b645021
commit
72795f8c0b
@ -1,8 +1,10 @@
|
|||||||
{ stdenv, writeText, erlang, rebar3, openssl,
|
{ stdenv, erlang, rebar3WithPlugins, openssl,
|
||||||
lib }:
|
lib }:
|
||||||
|
|
||||||
{ name, version
|
{ name, version
|
||||||
, src
|
, src
|
||||||
|
, beamDeps ? []
|
||||||
|
, buildPlugins ? []
|
||||||
, checkouts ? null
|
, checkouts ? null
|
||||||
, releaseType
|
, releaseType
|
||||||
, buildInputs ? []
|
, buildInputs ? []
|
||||||
@ -12,7 +14,6 @@
|
|||||||
, buildPhase ? null
|
, buildPhase ? null
|
||||||
, configurePhase ? null
|
, configurePhase ? null
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
, enableDebugInfo ? false
|
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
@ -27,28 +28,42 @@ let
|
|||||||
(_: v: v != null)
|
(_: v: v != null)
|
||||||
{ inherit setupHook configurePhase buildPhase installPhase; };
|
{ inherit setupHook configurePhase buildPhase installPhase; };
|
||||||
|
|
||||||
pkg = self: stdenv.mkDerivation (attrs // {
|
# When using the `beamDeps` argument, it is important that we use
|
||||||
|
# `rebar3WithPlugins` here even when there are no plugins. The vanilla
|
||||||
|
# `rebar3` package is an escript archive with bundled dependencies which can
|
||||||
|
# interfere with those in the app we are trying to build. `rebar3WithPlugins`
|
||||||
|
# doesn't have this issue since it puts its own deps last on the code path.
|
||||||
|
rebar3 = rebar3WithPlugins {
|
||||||
|
plugins = buildPlugins;
|
||||||
|
};
|
||||||
|
|
||||||
|
pkg =
|
||||||
|
assert beamDeps != [] -> checkouts == null;
|
||||||
|
self: stdenv.mkDerivation (attrs // {
|
||||||
|
|
||||||
name = "${name}-${version}";
|
name = "${name}-${version}";
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
buildInputs = buildInputs ++ [ erlang rebar3 openssl ];
|
buildInputs = buildInputs ++ [ erlang rebar3 openssl ] ++ beamDeps;
|
||||||
propagatedBuildInputs = [checkouts];
|
|
||||||
|
|
||||||
dontStrip = true;
|
dontStrip = true;
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
setupHook = writeText "setupHook.sh" ''
|
|
||||||
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
|
|
||||||
'';
|
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
${if checkouts != null then
|
${lib.optionalString (checkouts != null)
|
||||||
"cp --no-preserve=all -R ${checkouts}/_checkouts ."
|
"cp --no-preserve=all -R ${checkouts}/_checkouts ."}
|
||||||
else
|
${# Prevent rebar3 from trying to manage deps
|
||||||
""}
|
lib.optionalString (beamDeps != [ ]) ''
|
||||||
|
erl -noshell -eval '
|
||||||
|
{ok, Terms0} = file:consult("rebar.config"),
|
||||||
|
Terms = lists:keydelete(deps, 1, Terms0),
|
||||||
|
ok = file:write_file("rebar.config", [io_lib:format("~tp.~n", [T]) || T <- Terms]),
|
||||||
|
init:stop(0)
|
||||||
|
'
|
||||||
|
rm -f rebar.lock
|
||||||
|
''}
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user