nixpkgs/pkgs/development/erlang-modules/build-erlang.nix
Gleb Peregud acaf2c179e Allow specifying meta for buildHex and buildErlang.
Adds "meta" for meck package as a test.
2015-12-15 14:01:38 +01:00

66 lines
1.3 KiB
Nix

{ stdenv, erlang, rebar, openssl, libyaml }:
{ name, version
, buildInputs ? [], erlangDeps ? []
, postPatch ? ""
, meta ? {}
, ... }@attrs:
with stdenv.lib;
stdenv.mkDerivation (attrs // {
name = "${name}-${version}";
buildInputs = buildInputs ++ [ erlang rebar openssl libyaml ];
postPatch = ''
rm -f rebar
if [ -e "src/${name}.app.src" ]; then
sed -i -e 's/{ *vsn *,[^}]*}/{vsn, "${version}"}/' "src/${name}.app.src"
fi
${postPatch}
'';
configurePhase = let
getDeps = drv: [drv] ++ (map getDeps drv.erlangDeps);
recursiveDeps = uniqList {
inputList = flatten (map getDeps erlangDeps);
};
in ''
runHook preConfigure
${concatMapStrings (dep: ''
header "linking erlang dependency ${dep}"
mkdir deps
ln -s "${dep}" "deps/${dep.packageName}"
stopNest
'') recursiveDeps}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
rebar compile
runHook postBuild
'';
installPhase = ''
runHook preInstall
for reldir in src ebin priv include; do
[ -e "$reldir" ] || continue
mkdir "$out"
cp -rt "$out" "$reldir"
success=1
done
runHook postInstall
'';
meta = {
inherit (erlang.meta) platforms;
} // meta;
passthru = {
packageName = name;
inherit erlangDeps;
};
})