diff options
author | happysalada <raphael@megzari.com> | 2021-08-03 23:51:39 +0900 |
---|---|---|
committer | Raphael Megzari <raphael@megzari.com> | 2021-08-04 12:05:00 +0900 |
commit | b1b78ac65d9d91e3cb39a1996cc585721be1ec78 (patch) | |
tree | ae2c42124f2c04706f007611efa893a382fbfba4 | |
parent | fc2518d7d2a62d1a786342cd71fdb9eb14067f3a (diff) |
mix: add build mix and mix-release configure-hook
-rw-r--r-- | pkgs/development/beam-modules/build-mix.nix | 9 | ||||
-rwxr-xr-x | pkgs/development/beam-modules/mix-configure-hook.sh | 18 | ||||
-rw-r--r-- | pkgs/development/beam-modules/mix-release.nix | 15 |
3 files changed, 28 insertions, 14 deletions
diff --git a/pkgs/development/beam-modules/build-mix.nix b/pkgs/development/beam-modules/build-mix.nix index 728d249c97d8c..6b6ef7ce35014 100644 --- a/pkgs/development/beam-modules/build-mix.nix +++ b/pkgs/development/beam-modules/build-mix.nix @@ -42,6 +42,14 @@ let nativeBuildInputs = nativeBuildInputs ++ [ elixir hex ]; propagatedBuildInputs = propagatedBuildInputs ++ beamDeps; + configurePhase = attrs.configurePhase or '' + runHook preConfigure + + ${./mix-configure-hook.sh} + + runHook postConfigure + ''; + buildPhase = attrs.buildPhase or '' runHook preBuild export HEX_HOME="$TEMPDIR/hex" @@ -83,3 +91,4 @@ let }); in fix pkg + diff --git a/pkgs/development/beam-modules/mix-configure-hook.sh b/pkgs/development/beam-modules/mix-configure-hook.sh new file mode 100755 index 0000000000000..f8b4f3d159fe7 --- /dev/null +++ b/pkgs/development/beam-modules/mix-configure-hook.sh @@ -0,0 +1,18 @@ +# shellcheck shell=bash +# this hook will symlink all dependencies found in ERL_LIBS +# since Elixir 1.12.2 elixir does not look into ERL_LIBS for +# elixir depencencies anymore, so those have to be symlinked to the _build directory +mkdir -p _build/"$MIX_ENV"/lib +while read -r -d ':' lib; do + for dir in "$lib"/*; do + # Strip version number for directory name if it exists, so naming of + # all libs matches what mix's expectation. + dest=$(basename "$dir" | cut -d '-' -f1) + build_dir="_build/$MIX_ENV/lib/$dest" + ((MIX_DEBUG == 1)) && echo "Linking $dir to $build_dir" + # Symlink libs to _build so that mix can find them when compiling. + # This is what allows mix to compile the package without searching + # for dependencies over the network. + ln -s "$dir" "$build_dir" + done +done <<< "$ERL_LIBS:" diff --git a/pkgs/development/beam-modules/mix-release.nix b/pkgs/development/beam-modules/mix-release.nix index d9eea7c3b6f3e..c65e497f4d75b 100644 --- a/pkgs/development/beam-modules/mix-release.nix +++ b/pkgs/development/beam-modules/mix-release.nix @@ -58,20 +58,7 @@ stdenv.mkDerivation (overridable // { configurePhase = attrs.configurePhase or '' runHook preConfigure - mkdir -p _build/$MIX_ENV/lib - while read -d ':' lib; do - for dir in $lib/*; do - # Strip version number for directory name if it exists, so naming of - # all libs matches what mix's expectation. - dest=$(basename $dir | cut -d '-' -f1) - echo "Linking $dir to _build/$MIX_ENV/lib/$dest" - # Symlink libs to _build so that mix can find them when compiling. - # This is what allows mix to compile the package without searching - # for dependencies over the network. - ln -s $dir _build/$MIX_ENV/lib/$dest - done - done <<< "$ERL_LIBS:" - + ${./mix-configure-hook.sh} # this is needed for projects that have a specific compile step # the dependency needs to be compiled in order for the task # to be available |