Skip to content

Commit 7a30933

Browse files
committed
Show suggestion when Rust build fails
For issue #9
1 parent 2c464d6 commit 7a30933

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

fixtures/example/deps.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,31 @@ let
6161
ln -s "$lib" "priv/native/$(basename "$lib")"
6262
done
6363
'';
64+
65+
buildPhase = ''
66+
suggestion() {
67+
echo "***********************************************"
68+
echo " deps_nix "
69+
echo
70+
echo " Rust dependency build failed. "
71+
echo
72+
echo " If you saw network errors, you might need "
73+
echo " to disable compilation on the appropriate "
74+
echo " RustlerPrecompiled module in your "
75+
echo " application config. "
76+
echo
77+
echo " We think you need this: "
78+
echo
79+
echo -n " "
80+
grep -Rl 'use RustlerPrecompiled' lib \
81+
| xargs grep 'defmodule' \
82+
| sed 's/defmodule \(.*\) do/config :${old.packageName}, \1, skip_compilation?: true/'
83+
echo "***********************************************"
84+
exit 1
85+
}
86+
trap suggestion ERR
87+
${old.buildPhase}
88+
'';
6489
};
6590
};
6691

lib/deps_nix.ex

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,31 @@ defmodule DepsNix do
246246
ln -s "$lib" "priv/native/$(basename "$lib")"
247247
done
248248
'';
249+
250+
buildPhase = ''
251+
suggestion() {
252+
echo "***********************************************"
253+
echo " deps_nix "
254+
echo
255+
echo " Rust dependency build failed. "
256+
echo
257+
echo " If you saw network errors, you might need "
258+
echo " to disable compilation on the appropriate "
259+
echo " RustlerPrecompiled module in your "
260+
echo " application config. "
261+
echo
262+
echo " We think you need this: "
263+
echo
264+
echo -n " "
265+
grep -Rl 'use RustlerPrecompiled' lib \\
266+
| xargs grep 'defmodule' \\
267+
| sed 's/defmodule \\(.*\\) do/config :${old.packageName}, \\1, skip_compilation?: true/'
268+
echo "***********************************************"
269+
exit 1
270+
}
271+
trap suggestion ERR
272+
${old.buildPhase}
273+
'';
249274
};
250275
};
251276

0 commit comments

Comments
 (0)