diff options
author | Eric Merritt <eric@merritt.tech> | 2016-03-28 14:14:13 -0700 |
---|---|---|
committer | Eric Merritt <eric@merritt.tech> | 2016-04-23 19:03:24 -0700 |
commit | 8dbcb4e35ecc2513dab1ed8cb6052f68ab0a6537 (patch) | |
tree | 7c59313015440aa0adeed1acf01e9445081b308d /pkgs/development/beam-modules/build-mix.nix | |
parent | 3b7aee2e5a87b256aaff903a33106d974a25dbef (diff) |
beamPackages: Add support for Mix and Erlang.mk
Diffstat (limited to 'pkgs/development/beam-modules/build-mix.nix')
-rw-r--r-- | pkgs/development/beam-modules/build-mix.nix | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/pkgs/development/beam-modules/build-mix.nix b/pkgs/development/beam-modules/build-mix.nix new file mode 100644 index 0000000000000..12efc00b05096 --- /dev/null +++ b/pkgs/development/beam-modules/build-mix.nix @@ -0,0 +1,86 @@ +{ stdenv, writeText, elixir, erlang, hexRegistrySnapshot, hex }: + +{ name +, version +, src +, setupHook ? null +, buildInputs ? [] +, beamDeps ? [] +, postPatch ? "" +, compilePorts ? false +, installPhase ? null +, meta ? {} +, ... }@attrs: + +with stdenv.lib; + +let + shell = drv: stdenv.mkDerivation { + name = "interactive-shell-${drv.name}"; + buildInputs = [ drv ]; + }; + + bootstrapper = ./mix-bootstrap; + + pkg = self: stdenv.mkDerivation ( attrs // { + name = "${name}-${version}"; + inherit version; + + dontStrip = true; + + inherit src; + + setupHook = if setupHook == null + then writeText "setupHook.sh" '' + addToSearchPath ERL_LIBS "$1/lib/erlang/lib" + '' + else setupHook; + + inherit buildInputs; + propagatedBuildInputs = [ hexRegistrySnapshot hex elixir ] ++ beamDeps; + + configurePhase = '' + runHook preConfigure + ${erlang}/bin/escript ${bootstrapper} + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + + export HEX_OFFLINE=1 + export HEX_HOME=`pwd` + export MIX_ENV=prod + + MIX_ENV=prod mix compile --debug-info --no-deps-check + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + MIXENV=prod + + if [ -d "_build/shared" ]; then + MIXENV=shared + fi + + mkdir -p "$out/lib/erlang/lib/${name}-${version}" + for reldir in src ebin priv include; do + fd="_build/$MIXENV/lib/${name}/$reldir" + [ -d "$fd" ] || continue + cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$fd" + success=1 + done + + runHook postInstall + ''; + + passthru = { + packageName = name; + env = shell self; + inherit beamDeps; + }; +}); +in fix pkg |