beamPackages: add the ability to override phases

This commit is contained in:
Eric Merritt 2016-06-15 07:19:44 -07:00
parent 285aee3c12
commit 2e61bd72a1
3 changed files with 40 additions and 16 deletions

View File

@ -8,6 +8,8 @@
, postPatch ? ""
, compilePorts ? false
, installPhase ? null
, buildPhase ? null
, configurePhase ? null
, meta ? {}
, ... }@attrs:
@ -37,7 +39,8 @@ let
buildInputs = [ erlang perl which gitMinimal wget ];
propagatedBuildInputs = beamDeps;
configurePhase = ''
configurePhase = if configurePhase == null
then ''
runHook preConfigure
# We shouldnt need to do this, but it seems at times there is a *.app in
@ -45,17 +48,21 @@ let
make SKIP_DEPS=1 clean
runHook postConfigure
'';
''
else configurePhase;
buildPhase = ''
buildPhase = if buildPhase == null
then ''
runHook preBuild
make SKIP_DEPS=1
runHook postBuild
'';
''
else buildPhase;
installPhase = ''
installPhase = if installPhase == null
then ''
runHook preInstall
mkdir -p $out/lib/erlang/lib/${name}
@ -75,7 +82,8 @@ let
fi
runHook postInstall
'';
''
else installPhase;
passthru = {
packageName = name;

View File

@ -8,6 +8,9 @@
, beamDeps ? []
, postPatch ? ""
, compilePorts ? false
, installPhase ? null
, buildPhase ? null
, configurePhase ? null
, meta ? {}
, ... }@attrs:
@ -38,13 +41,17 @@ let
inherit buildInputs;
propagatedBuildInputs = [ hexRegistrySnapshot hex elixir ] ++ beamDeps;
configurePhase = ''
configurePhase = if configurePhase == null
then ''
runHook preConfigure
${erlang}/bin/escript ${bootstrapper}
runHook postConfigure
'';
''
else configurePhase ;
buildPhase = ''
buildPhase = if buildPhase == null
then ''
runHook preBuild
export HEX_OFFLINE=1
@ -54,9 +61,11 @@ let
MIX_ENV=prod mix compile --debug-info --no-deps-check
runHook postBuild
'';
''
else buildPhase;
installPhase = ''
installPhase = if installPhase == null
then ''
runHook preInstall
MIXENV=prod
@ -74,7 +83,8 @@ let
done
runHook postInstall
'';
''
else installPhase;
passthru = {
packageName = name;

View File

@ -8,6 +8,8 @@
, postPatch ? ""
, compilePorts ? false
, installPhase ? null
, buildPhase ? null
, configurePhase ? null
, meta ? {}
, ... }@attrs:
@ -46,20 +48,24 @@ let
rm -f rebar rebar3
'';
configurePhase = ''
configurePhase = if configurePhase == null
then ''
runHook preConfigure
${erlang}/bin/escript ${rebar3.bootstrapper}
runHook postConfigure
'';
''
else configurePhase;
buildPhase = ''
buildPhase = if buildPhase == null
then ''
runHook preBuild
HOME=. rebar3 compile
${if compilePorts then ''
HOME=. rebar3 pc compile
'' else ''''}
runHook postBuild
'';
''
else installPhase;
installPhase = if installPhase == null
then ''