2019-10-19 17:37:44 +02:00
|
|
|
{ stdenv, writeText, elixir, erlang, hex, lib }:
|
2016-03-28 23:14:13 +02:00
|
|
|
|
|
|
|
{ name
|
|
|
|
, version
|
|
|
|
, src
|
|
|
|
, setupHook ? null
|
|
|
|
, buildInputs ? []
|
|
|
|
, beamDeps ? []
|
|
|
|
, postPatch ? ""
|
|
|
|
, compilePorts ? false
|
2016-06-15 16:19:44 +02:00
|
|
|
, installPhase ? null
|
|
|
|
, buildPhase ? null
|
|
|
|
, configurePhase ? null
|
2016-03-28 23:14:13 +02:00
|
|
|
, meta ? {}
|
2016-06-15 16:15:06 +02:00
|
|
|
, enableDebugInfo ? false
|
2016-03-28 23:14:13 +02:00
|
|
|
, ... }@attrs:
|
|
|
|
|
2021-01-23 18:15:07 +01:00
|
|
|
with lib;
|
2016-03-28 23:14:13 +02:00
|
|
|
|
|
|
|
let
|
2016-06-15 16:15:06 +02:00
|
|
|
|
|
|
|
debugInfoFlag = lib.optionalString (enableDebugInfo || elixir.debugInfo) "--debug-info";
|
|
|
|
|
2016-03-28 23:14:13 +02:00
|
|
|
shell = drv: stdenv.mkDerivation {
|
|
|
|
name = "interactive-shell-${drv.name}";
|
|
|
|
buildInputs = [ drv ];
|
|
|
|
};
|
|
|
|
|
|
|
|
bootstrapper = ./mix-bootstrap;
|
|
|
|
|
|
|
|
pkg = self: stdenv.mkDerivation ( attrs // {
|
|
|
|
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;
|
|
|
|
|
|
|
|
inherit buildInputs;
|
2019-10-19 17:37:44 +02:00
|
|
|
propagatedBuildInputs = [ hex elixir ] ++ beamDeps;
|
2016-03-28 23:14:13 +02:00
|
|
|
|
2016-06-15 16:19:44 +02:00
|
|
|
configurePhase = if configurePhase == null
|
|
|
|
then ''
|
2016-03-28 23:14:13 +02:00
|
|
|
runHook preConfigure
|
|
|
|
${erlang}/bin/escript ${bootstrapper}
|
|
|
|
runHook postConfigure
|
2016-06-15 16:19:44 +02:00
|
|
|
''
|
|
|
|
else configurePhase ;
|
|
|
|
|
2016-03-28 23:14:13 +02:00
|
|
|
|
2016-06-15 16:19:44 +02:00
|
|
|
buildPhase = if buildPhase == null
|
|
|
|
then ''
|
2016-03-28 23:14:13 +02:00
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
export HEX_OFFLINE=1
|
|
|
|
export HEX_HOME=`pwd`
|
|
|
|
export MIX_ENV=prod
|
2017-05-09 07:59:24 +02:00
|
|
|
export MIX_NO_DEPS=1
|
2016-03-28 23:14:13 +02:00
|
|
|
|
2019-07-02 13:22:17 +02:00
|
|
|
mix compile ${debugInfoFlag} --no-deps-check
|
2016-03-28 23:14:13 +02:00
|
|
|
|
|
|
|
runHook postBuild
|
2016-06-15 16:19:44 +02:00
|
|
|
''
|
|
|
|
else buildPhase;
|
2016-03-28 23:14:13 +02:00
|
|
|
|
2016-06-15 16:19:44 +02:00
|
|
|
installPhase = if installPhase == null
|
|
|
|
then ''
|
2016-03-28 23:14:13 +02:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
MIXENV=prod
|
|
|
|
|
|
|
|
if [ -d "_build/shared" ]; then
|
|
|
|
MIXENV=shared
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "$out/lib/erlang/lib/${name}-${version}"
|
|
|
|
for reldir in src ebin priv include; do
|
|
|
|
fd="_build/$MIXENV/lib/${name}/$reldir"
|
|
|
|
[ -d "$fd" ] || continue
|
|
|
|
cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$fd"
|
|
|
|
success=1
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postInstall
|
2016-06-15 16:19:44 +02:00
|
|
|
''
|
|
|
|
else installPhase;
|
2016-03-28 23:14:13 +02:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
packageName = name;
|
|
|
|
env = shell self;
|
|
|
|
inherit beamDeps;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
in fix pkg
|