2016-06-15 15:15:06 +01:00
|
|
|
{ stdenv, writeText, erlang, perl, which, gitMinimal, wget, lib }:
|
2016-03-28 22:14:13 +01:00
|
|
|
|
|
|
|
{ name, version
|
|
|
|
, src
|
|
|
|
, setupHook ? null
|
|
|
|
, buildInputs ? []
|
|
|
|
, beamDeps ? []
|
|
|
|
, postPatch ? ""
|
|
|
|
, compilePorts ? false
|
|
|
|
, installPhase ? null
|
2016-06-15 15:19:44 +01:00
|
|
|
, buildPhase ? null
|
|
|
|
, configurePhase ? null
|
2016-03-28 22:14:13 +01:00
|
|
|
, meta ? {}
|
2016-06-15 15:15:06 +01:00
|
|
|
, enableDebugInfo ? false
|
2016-03-28 22:14:13 +01:00
|
|
|
, ... }@attrs:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
2016-06-15 15:15:06 +01:00
|
|
|
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
|
|
|
|
|
2016-03-28 22:14:13 +01:00
|
|
|
shell = drv: stdenv.mkDerivation {
|
|
|
|
name = "interactive-shell-${drv.name}";
|
|
|
|
buildInputs = [ drv ];
|
|
|
|
};
|
|
|
|
|
|
|
|
pkg = self: stdenv.mkDerivation ( attrs // {
|
2019-09-09 00:38:31 +01:00
|
|
|
app_name = name;
|
2016-03-28 22:14:13 +01:00
|
|
|
name = "${name}-${version}";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
setupHook = if setupHook == null
|
|
|
|
then writeText "setupHook.sh" ''
|
|
|
|
addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
|
|
|
|
''
|
|
|
|
else setupHook;
|
|
|
|
|
|
|
|
buildInputs = [ erlang perl which gitMinimal wget ];
|
|
|
|
propagatedBuildInputs = beamDeps;
|
|
|
|
|
2016-06-15 15:19:44 +01:00
|
|
|
configurePhase = if configurePhase == null
|
|
|
|
then ''
|
2016-03-28 22:14:13 +01:00
|
|
|
runHook preConfigure
|
|
|
|
|
|
|
|
# We shouldnt need to do this, but it seems at times there is a *.app in
|
|
|
|
# the repo/package. This ensures we start from a clean slate
|
|
|
|
make SKIP_DEPS=1 clean
|
|
|
|
|
|
|
|
runHook postConfigure
|
2016-06-15 15:19:44 +01:00
|
|
|
''
|
|
|
|
else configurePhase;
|
2016-03-28 22:14:13 +01:00
|
|
|
|
2016-06-15 15:19:44 +01:00
|
|
|
buildPhase = if buildPhase == null
|
|
|
|
then ''
|
2016-03-28 22:14:13 +01:00
|
|
|
runHook preBuild
|
|
|
|
|
2016-06-15 15:15:06 +01:00
|
|
|
make SKIP_DEPS=1 ERL_OPTS="$ERL_OPTS ${debugInfoFlag}"
|
2016-03-28 22:14:13 +01:00
|
|
|
|
|
|
|
runHook postBuild
|
2016-06-15 15:19:44 +01:00
|
|
|
''
|
|
|
|
else buildPhase;
|
2016-03-28 22:14:13 +01:00
|
|
|
|
2016-06-15 15:19:44 +01:00
|
|
|
installPhase = if installPhase == null
|
|
|
|
then ''
|
2016-03-28 22:14:13 +01:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/lib/erlang/lib/${name}
|
|
|
|
cp -r ebin $out/lib/erlang/lib/${name}/
|
|
|
|
cp -r src $out/lib/erlang/lib/${name}/
|
|
|
|
|
|
|
|
if [ -d include ]; then
|
|
|
|
cp -r include $out/lib/erlang/lib/${name}/
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d priv ]; then
|
|
|
|
cp -r priv $out/lib/erlang/lib/${name}/
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d doc ]; then
|
|
|
|
cp -r doc $out/lib/erlang/lib/${name}/
|
|
|
|
fi
|
|
|
|
|
|
|
|
runHook postInstall
|
2016-06-15 15:19:44 +01:00
|
|
|
''
|
|
|
|
else installPhase;
|
2016-03-28 22:14:13 +01:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
packageName = name;
|
|
|
|
env = shell self;
|
|
|
|
inherit beamDeps;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
in fix pkg
|