2019-10-19 16:37:44 +01:00
|
|
|
{ stdenv, writeText, elixir, erlang, hex, lib }:
|
2016-03-28 22:14:13 +01:00
|
|
|
|
|
|
|
{ name
|
|
|
|
, version
|
|
|
|
, src
|
|
|
|
, setupHook ? null
|
|
|
|
, buildInputs ? []
|
|
|
|
, beamDeps ? []
|
|
|
|
, postPatch ? ""
|
|
|
|
, compilePorts ? false
|
2016-06-15 15:19:44 +01:00
|
|
|
, installPhase ? null
|
|
|
|
, 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:
|
|
|
|
|
2021-01-23 17:15:07 +00:00
|
|
|
with lib;
|
2016-03-28 22:14:13 +01:00
|
|
|
|
|
|
|
let
|
2016-06-15 15:15:06 +01:00
|
|
|
|
|
|
|
debugInfoFlag = lib.optionalString (enableDebugInfo || elixir.debugInfo) "--debug-info";
|
|
|
|
|
2016-03-28 22:14:13 +01: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 16:37:44 +01:00
|
|
|
propagatedBuildInputs = [ hex elixir ] ++ beamDeps;
|
2016-03-28 22:14:13 +01:00
|
|
|
|
2016-06-15 15:19:44 +01:00
|
|
|
configurePhase = if configurePhase == null
|
|
|
|
then ''
|
2016-03-28 22:14:13 +01:00
|
|
|
runHook preConfigure
|
|
|
|
${erlang}/bin/escript ${bootstrapper}
|
|
|
|
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
|
|
|
|
|
|
|
|
export HEX_OFFLINE=1
|
|
|
|
export HEX_HOME=`pwd`
|
|
|
|
export MIX_ENV=prod
|
2017-05-09 06:59:24 +01:00
|
|
|
export MIX_NO_DEPS=1
|
2016-03-28 22:14:13 +01:00
|
|
|
|
2019-07-02 12:22:17 +01:00
|
|
|
mix compile ${debugInfoFlag} --no-deps-check
|
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
|
|
|
|
|
|
|
|
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 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
|