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

View File

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

View File

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