summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-07-12 16:56:14 +0200
committertv <tv@krebsco.de>2017-07-12 17:01:39 +0200
commit8fc6574c63d5727ef36292f24297bb291b9b4f06 (patch)
tree6fe00af787782bb605972a51f06c76183a2ccbf0 /krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
parent7fdc46bb9d911838edfa723d985ede6a604c0c5a (diff)
whatsupnix: exit != 0 on Nix errors
Diffstat (limited to 'krebs/5pkgs/simple/whatsupnix/whatsupnix.bash')
-rw-r--r--krebs/5pkgs/simple/whatsupnix/whatsupnix.bash27
1 files changed, 22 insertions, 5 deletions
diff --git a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
index 2ad9aadc9..e21e0f1b3 100644
--- a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
+++ b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
@@ -14,15 +14,30 @@
#
# 1 Usage error; arguments couldn't be parsed.
#
-# 2 Build error; at least one failed derivation could be found.
+# 2 Nix error; input looks like Nix failed.
+#
+# 3 Build error; at least one failed derivation could be found.
#
-failed_drvs=$(mktemp --tmpdir whatsupnix.XXXXXXXX)
-trap 'rm -f -- "$failed_drvs"' EXIT
+tmpdir=$(mktemp -d --tmpdir whatsupnix.XXXXXXXX)
+failed_drvs=$tmpdir/failed_drvs; touch "$failed_drvs"
+nix_errors=$tmpdir/nix_errors; touch "$nix_errors"
+cleanup() {
+ rm "$failed_drvs"
+ rm "$nix_errors"
+ rmdir "$tmpdir"
+}
+trap cleanup EXIT
exec >&2
-gawk -v failed_drvs="$failed_drvs" '
+gawk \
+ -v failed_drvs="$failed_drvs" \
+ -v nix_errors="$nix_errors" \
+'
+ /^(\033\[31;1m)?error:/ {
+ print $0 >> nix_errors
+ }
match($0, /^builder for ‘(\/nix\/store\/[^’]+\.drv)’ failed/, m) {
print m[1] >> failed_drvs
}
@@ -73,8 +88,10 @@ while read -r drv; do
echo
done < "$failed_drvs"
-if test -s "$failed_drvs"; then
+if test -s "$nix_errors"; then
exit 2
+elif test -s "$failed_drvs"; then
+ exit 3
else
exit 0
fi