summary refs log tree commit diff
path: root/pkgs/development/beam-modules/fetch-mix-deps.nix
diff options
context:
space:
mode:
authorhappysalada <raphael@megzari.com>2021-04-08 20:54:48 +0900
committerhappysalada <raphael@megzari.com>2021-04-08 20:54:48 +0900
commit481832b32db4a9b1de5b5a04e9038520ff03fac3 (patch)
tree4cb50f02e3e82f354e7c6f67ad344cc0b9403b08 /pkgs/development/beam-modules/fetch-mix-deps.nix
parent1b1af195bb1e02a5d0548d27a11a5e12d377d62a (diff)
downloadnixpkgs-481832b32db4a9b1de5b5a04e9038520ff03fac3.tar
nixpkgs-481832b32db4a9b1de5b5a04e9038520ff03fac3.tar.gz
nixpkgs-481832b32db4a9b1de5b5a04e9038520ff03fac3.tar.bz2
nixpkgs-481832b32db4a9b1de5b5a04e9038520ff03fac3.tar.lz
nixpkgs-481832b32db4a9b1de5b5a04e9038520ff03fac3.tar.xz
nixpkgs-481832b32db4a9b1de5b5a04e9038520ff03fac3.tar.zst
nixpkgs-481832b32db4a9b1de5b5a04e9038520ff03fac3.zip
beam-modules: buildMix -> mixRelease
Diffstat (limited to 'pkgs/development/beam-modules/fetch-mix-deps.nix')
-rw-r--r--pkgs/development/beam-modules/fetch-mix-deps.nix41
1 files changed, 28 insertions, 13 deletions
diff --git a/pkgs/development/beam-modules/fetch-mix-deps.nix b/pkgs/development/beam-modules/fetch-mix-deps.nix
index 020a82ad70b..73365bd1a93 100644
--- a/pkgs/development/beam-modules/fetch-mix-deps.nix
+++ b/pkgs/development/beam-modules/fetch-mix-deps.nix
@@ -1,34 +1,49 @@
 { stdenvNoCC, lib, elixir, hex, rebar, rebar3, cacert, git }:
 
-{ name, version, sha256, src, mixEnv ? "prod", debug ? false, meta ? { } }:
-
-stdenvNoCC.mkDerivation ({
-  name = "mix-deps-${name}-${version}";
-
+{ pname
+, version
+, sha256
+, src
+, mixEnv ? "prod"
+, debug ? false
+, meta ? { }
+, ...
+}@attrs:
+
+stdenvNoCC.mkDerivation (attrs // {
   nativeBuildInputs = [ elixir hex cacert git ];
 
-  inherit src;
-
   MIX_ENV = mixEnv;
   MIX_DEBUG = if debug then 1 else 0;
   DEBUG = if debug then 1 else 0; # for rebar3
-
-  configurePhase = ''
+  # the api with `mix local.rebar rebar path` makes a copy of the binary
+  MIX_REBAR = "${rebar}/bin/rebar";
+  MIX_REBAR3 = "${rebar3}/bin/rebar3";
+  # there is a persistent download failure with absinthe 1.6.3
+  # those defaults reduce the failure rate
+  HEX_HTTP_CONCURRENCY = 1;
+  HEX_HTTP_TIMEOUT = 120;
+
+  configurePhase = attrs.configurePhase or ''
+    runHook preConfigure
     export HEX_HOME="$TEMPDIR/.hex";
     export MIX_HOME="$TEMPDIR/.mix";
-    export MIX_DEPS_PATH="$out";
+    export MIX_DEPS_PATH="$TEMPDIR/deps";
 
     # Rebar
-    mix local.rebar rebar "${rebar}/bin/rebar"
-    mix local.rebar rebar3 "${rebar3}/bin/rebar3"
     export REBAR_GLOBAL_CONFIG_DIR="$TMPDIR/rebar3"
     export REBAR_CACHE_DIR="$TMPDIR/rebar3.cache"
+    runHook postConfigure
   '';
 
   dontBuild = true;
 
-  installPhase = ''
+  installPhase = attrs.installPhase or ''
+    runHook preInstall
     mix deps.get --only ${mixEnv}
+    find "$TEMPDIR/deps" -path '*/.git/*' -a ! -name HEAD -exec rm -rf {} +
+    cp -r --no-preserve=mode,ownership,timestamps $TEMPDIR/deps $out
+    runHook postInstall
   '';
 
   outputHashAlgo = "sha256";