nixpkgs/pkgs/development/beam-modules/build-erlang-mk.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

136 lines
2.8 KiB
Nix
Raw Normal View History

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