nixpkgs/pkgs/development/erlang-modules/build-erlang.nix
Gleb Peregud d7e17c2e71 Add shell env to buildHex packages.
This adds erlangPackages.${name}.env, which is usable to launch a shell
with the package and it's dependencies like this:

    nix-shell -A erlangPackages.lager.env

This required:

1) refactoring buildHex to become a fixed-point function,
2) moves output of a package into $out/${name},
3) introduces erlEnv (buildEnv, which links in package and it's deps
   into one directory - a super-simple plagiarization of
   haskellPackages.compiler.ghcWithPackages) and
4) shell function producing a un-buildable derivation to be used by
   nix-shell
2015-12-19 00:07:54 +01:00

69 lines
1.4 KiB
Nix

# This file is not used not tested at this time, build-hex.nix is the currently
# main vehicle of bringing Erlang packages in.
{ 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;
};
})