2019-06-16 20:59:06 +01:00
|
|
|
{ stdenv, writeText, erlang, rebar3, openssl,
|
|
|
|
lib }:
|
2019-01-16 21:51:19 +00:00
|
|
|
|
|
|
|
{ name, version
|
|
|
|
, src
|
|
|
|
, checkouts ? null
|
|
|
|
, releaseType
|
|
|
|
, buildInputs ? []
|
|
|
|
, setupHook ? null
|
|
|
|
, profile ? "default"
|
|
|
|
, installPhase ? null
|
|
|
|
, buildPhase ? null
|
|
|
|
, configurePhase ? null
|
|
|
|
, meta ? {}
|
|
|
|
, enableDebugInfo ? false
|
|
|
|
, ... }@attrs:
|
|
|
|
|
2021-01-23 17:15:07 +00:00
|
|
|
with lib;
|
2019-01-16 21:51:19 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
shell = drv: stdenv.mkDerivation {
|
|
|
|
name = "interactive-shell-${drv.name}";
|
|
|
|
buildInputs = [ drv ];
|
|
|
|
};
|
|
|
|
|
|
|
|
customPhases = filterAttrs
|
|
|
|
(_: v: v != null)
|
|
|
|
{ inherit setupHook configurePhase buildPhase installPhase; };
|
|
|
|
|
|
|
|
pkg = self: stdenv.mkDerivation (attrs // {
|
|
|
|
|
|
|
|
name = "${name}-${version}";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
buildInputs = buildInputs ++ [ erlang rebar3 openssl ];
|
|
|
|
propagatedBuildInputs = [checkouts];
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
setupHook = writeText "setupHook.sh" ''
|
|
|
|
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
|
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
${if checkouts != null then
|
2021-01-24 09:19:10 +00:00
|
|
|
"cp --no-preserve=all -R ${checkouts}/_checkouts ."
|
2019-01-16 21:51:19 +00:00
|
|
|
else
|
2021-01-24 09:19:10 +00:00
|
|
|
""}
|
2019-01-16 21:51:19 +00:00
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
HOME=. DEBUG=1 rebar3 as ${profile} ${if releaseType == "escript"
|
2021-01-24 09:19:10 +00:00
|
|
|
then "escriptize"
|
|
|
|
else "release"}
|
2019-01-16 21:51:19 +00:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
dir=${if releaseType == "escript"
|
2021-01-24 09:19:10 +00:00
|
|
|
then "bin"
|
|
|
|
else "rel"}
|
2019-01-16 21:51:19 +00:00
|
|
|
mkdir -p "$out/$dir"
|
|
|
|
cp -R --preserve=mode "_build/${profile}/$dir" "$out"
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
inherit (erlang.meta) platforms;
|
|
|
|
} // meta;
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
packageName = name;
|
|
|
|
env = shell self;
|
|
|
|
};
|
|
|
|
} // customPhases);
|
|
|
|
in
|
|
|
|
fix pkg
|