2016-06-15 14:15:06 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
writeText,
|
|
|
|
erlang,
|
|
|
|
perl,
|
|
|
|
which,
|
|
|
|
gitMinimal,
|
|
|
|
wget,
|
|
|
|
lib,
|
|
|
|
}:
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-03 12:58:02 +00:00
|
|
|
{
|
|
|
|
name,
|
|
|
|
version,
|
2016-03-28 21:14:13 +00:00
|
|
|
src,
|
|
|
|
setupHook ? null,
|
2021-06-03 12:58:02 +00:00
|
|
|
buildInputs ? [ ],
|
|
|
|
beamDeps ? [ ],
|
2016-03-28 21:14:13 +00:00
|
|
|
postPatch ? "",
|
|
|
|
compilePorts ? false,
|
|
|
|
installPhase ? null,
|
2016-06-15 14:19:44 +00:00
|
|
|
buildPhase ? null,
|
|
|
|
configurePhase ? null,
|
2021-06-03 12:58:02 +00:00
|
|
|
meta ? { },
|
2016-06-15 14:15:06 +00:00
|
|
|
enableDebugInfo ? false,
|
2021-06-03 12:58:02 +00:00
|
|
|
buildFlags ? [ ],
|
|
|
|
...
|
|
|
|
}@attrs:
|
2016-03-28 21:14:13 +00:00
|
|
|
|
|
|
|
let
|
2016-06-15 14:15:06 +00:00
|
|
|
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
|
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
shell =
|
2021-06-03 12:58:02 +00:00
|
|
|
drv:
|
|
|
|
stdenv.mkDerivation {
|
2016-03-28 21:14:13 +00:00
|
|
|
name = "interactive-shell-${drv.name}";
|
|
|
|
buildInputs = [ drv ];
|
|
|
|
};
|
2024-12-10 19:26:33 +00:00
|
|
|
|
|
|
|
pkg =
|
|
|
|
self:
|
2021-06-03 12:58:02 +00:00
|
|
|
stdenv.mkDerivation (
|
2024-12-10 19:26:33 +00:00
|
|
|
attrs
|
|
|
|
// {
|
2019-09-08 23:38:31 +00:00
|
|
|
app_name = name;
|
2016-03-28 21:14:13 +00:00
|
|
|
name = "${name}-${version}";
|
|
|
|
inherit version;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
dontStrip = true;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
inherit src;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-03 12:58:02 +00:00
|
|
|
setupHook =
|
|
|
|
if setupHook == null then
|
|
|
|
writeText "setupHook.sh" ''
|
|
|
|
addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
|
2024-12-10 19:26:33 +00:00
|
|
|
''
|
|
|
|
else
|
2021-06-03 12:58:02 +00:00
|
|
|
setupHook;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2020-09-15 20:47:55 +00:00
|
|
|
buildInputs = buildInputs ++ [
|
2024-12-10 19:26:33 +00:00
|
|
|
erlang
|
|
|
|
perl
|
|
|
|
which
|
2020-09-15 20:47:55 +00:00
|
|
|
gitMinimal
|
2024-12-10 19:26:33 +00:00
|
|
|
wget
|
|
|
|
];
|
2016-03-28 21:14:13 +00:00
|
|
|
propagatedBuildInputs = beamDeps;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2020-09-14 16:48:14 +00:00
|
|
|
buildFlags =
|
|
|
|
[ "SKIP_DEPS=1" ]
|
|
|
|
++ lib.optional (enableDebugInfo || erlang.debugInfo) ''ERL_OPTS="$ERL_OPTS +debug_info"''
|
|
|
|
++ buildFlags;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-03 12:58:02 +00:00
|
|
|
configurePhase =
|
|
|
|
if configurePhase == null then
|
2024-12-10 19:26:33 +00:00
|
|
|
''
|
2021-06-03 12:58:02 +00:00
|
|
|
runHook preConfigure
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-03 12:58:02 +00:00
|
|
|
# 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
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-03 12:58:02 +00:00
|
|
|
runHook postConfigure
|
2024-12-10 19:26:33 +00:00
|
|
|
''
|
|
|
|
else
|
2021-06-03 12:58:02 +00:00
|
|
|
configurePhase;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-03 12:58:02 +00:00
|
|
|
buildPhase =
|
|
|
|
if buildPhase == null then
|
2024-12-10 19:26:33 +00:00
|
|
|
''
|
2016-03-28 21:14:13 +00:00
|
|
|
runHook preBuild
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2020-09-14 16:48:14 +00:00
|
|
|
make $buildFlags "''${buildFlagsArray[@]}"
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
runHook postBuild
|
2024-12-10 19:26:33 +00:00
|
|
|
''
|
|
|
|
else
|
2021-06-03 12:58:02 +00:00
|
|
|
buildPhase;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2021-06-03 12:58:02 +00:00
|
|
|
installPhase =
|
|
|
|
if installPhase == null then
|
2024-12-10 19:26:33 +00:00
|
|
|
''
|
2016-03-28 21:14:13 +00:00
|
|
|
runHook preInstall
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
mkdir -p $out/lib/erlang/lib/${name}
|
|
|
|
cp -r ebin $out/lib/erlang/lib/${name}/
|
|
|
|
cp -r src $out/lib/erlang/lib/${name}/
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
if [ -d include ]; then
|
|
|
|
cp -r include $out/lib/erlang/lib/${name}/
|
2024-12-10 19:26:33 +00:00
|
|
|
fi
|
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
if [ -d priv ]; then
|
|
|
|
cp -r priv $out/lib/erlang/lib/${name}/
|
2024-12-10 19:26:33 +00:00
|
|
|
fi
|
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
if [ -d doc ]; then
|
|
|
|
cp -r doc $out/lib/erlang/lib/${name}/
|
2024-12-10 19:26:33 +00:00
|
|
|
fi
|
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
runHook postInstall
|
2024-12-10 19:26:33 +00:00
|
|
|
''
|
|
|
|
else
|
2021-06-03 12:58:02 +00:00
|
|
|
installPhase;
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2016-03-28 21:14:13 +00:00
|
|
|
passthru = {
|
|
|
|
packageName = name;
|
|
|
|
env = shell self;
|
|
|
|
inherit beamDeps;
|
2021-06-03 12:58:02 +00:00
|
|
|
};
|
2024-12-10 19:26:33 +00:00
|
|
|
}
|
2021-06-03 12:58:02 +00:00
|
|
|
);
|
|
|
|
in
|
2023-01-26 17:31:02 +00:00
|
|
|
lib.fix pkg
|