2016-03-29 00:14:13 +03:00
|
|
|
{ stdenv, writeText, erlang, rebar3, openssl, libyaml,
|
2016-01-10 02:42:28 +03:00
|
|
|
pc, buildEnv }:
|
2016-01-11 02:25:45 +03:00
|
|
|
|
|
|
|
{ name, version
|
|
|
|
, src
|
|
|
|
, setupHook ? null
|
2016-03-29 00:14:13 +03:00
|
|
|
, buildInputs ? [], beamDeps ? [], buildPlugins ? []
|
2016-01-11 02:25:45 +03:00
|
|
|
, postPatch ? ""
|
|
|
|
, compilePorts ? false
|
2016-01-11 05:39:37 +03:00
|
|
|
, installPhase ? null
|
2016-01-11 02:25:45 +03:00
|
|
|
, meta ? {}
|
|
|
|
, ... }@attrs:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
2016-01-17 23:00:12 +03:00
|
|
|
ownPlugins = buildPlugins ++ (if compilePorts then [pc] else []);
|
2016-01-11 02:25:45 +03:00
|
|
|
|
|
|
|
shell = drv: stdenv.mkDerivation {
|
|
|
|
name = "interactive-shell-${drv.name}";
|
|
|
|
buildInputs = [ drv ];
|
|
|
|
};
|
|
|
|
|
|
|
|
pkg = self: stdenv.mkDerivation (attrs // {
|
|
|
|
|
|
|
|
name = "${name}-${version}";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
buildInputs = buildInputs ++ [ erlang rebar3 openssl libyaml ];
|
2016-03-29 00:14:13 +03:00
|
|
|
propagatedBuildInputs = unique (beamDeps ++ ownPlugins);
|
2016-01-17 23:00:12 +03:00
|
|
|
|
2016-03-29 00:14:13 +03:00
|
|
|
dontStrip = true;
|
2016-01-17 23:00:12 +03:00
|
|
|
# The following are used by rebar3-nix-bootstrap
|
|
|
|
inherit compilePorts;
|
|
|
|
buildPlugins = ownPlugins;
|
2016-01-11 02:25:45 +03:00
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
|
|
|
setupHook = if setupHook == null
|
|
|
|
then writeText "setupHook.sh" ''
|
|
|
|
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
|
|
|
|
''
|
|
|
|
else setupHook;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
rm -f rebar rebar3
|
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
2016-04-15 21:06:57 +03:00
|
|
|
${erlang}/bin/escript ${rebar3.bootstrapper}
|
2016-01-11 02:25:45 +03:00
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
HOME=. rebar3 compile
|
|
|
|
${if compilePorts then ''
|
|
|
|
HOME=. rebar3 pc compile
|
|
|
|
'' else ''''}
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2016-01-11 05:39:37 +03:00
|
|
|
installPhase = if installPhase == null
|
|
|
|
then ''
|
2016-01-11 02:25:45 +03:00
|
|
|
runHook preInstall
|
|
|
|
mkdir -p "$out/lib/erlang/lib/${name}-${version}"
|
|
|
|
for reldir in src ebin priv include; do
|
|
|
|
fd="_build/default/lib/${name}/$reldir"
|
|
|
|
[ -d "$fd" ] || continue
|
|
|
|
cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$fd"
|
|
|
|
success=1
|
|
|
|
done
|
|
|
|
runHook postInstall
|
2016-01-11 05:39:37 +03:00
|
|
|
''
|
|
|
|
else installPhase;
|
2016-01-11 02:25:45 +03:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
inherit (erlang.meta) platforms;
|
|
|
|
} // meta;
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
packageName = name;
|
|
|
|
env = shell self;
|
2016-03-29 00:14:13 +03:00
|
|
|
inherit beamDeps;
|
2016-01-11 02:25:45 +03:00
|
|
|
};
|
|
|
|
});
|
|
|
|
in
|
|
|
|
fix pkg
|