From 8b784c24b1190ed5ea35b699152d43c61481302f Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 17 Jun 2020 15:31:55 -0700 Subject: bild: print log output if the build fails This also switches to using `nix-build` instead of `nix build`. The reason for this is that the latter does something with the stdout/stderr that makes it hard to capture via tee. Idk why. Maybe I'll look into this again, or maybe not, since nix-build works just fine. --- bild | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bild b/bild index 8ea07ea..fdd3dd7 100755 --- a/bild +++ b/bild @@ -3,9 +3,23 @@ set -ex prefix=$(echo $PWD | sed -e "s|^$BIZ_ROOT/*||g" -e "s|/|.|g") if [[ "$prefix" == "" ]] then + # TODO: make this accept any number of build targets target="$1" else target="$prefix.$1" fi -nix build -o "$BIZ_ROOT/_bild/$target" \ - -f $BIZ_ROOT/default.nix "$target" --show-trace +log=$(mktemp) +nix-build \ + -o "$BIZ_ROOT/_bild/$target" \ + $BIZ_ROOT/default.nix \ + --attr "$target" \ + --show-trace \ + 2>&1 \ + | tee $log +if [[ ${PIPESTATUS[0]} != 0 ]] +then + o=$(gawk "match(\$0, /'(.*)'\sfailed/, a) {print a[1]}" $log \ + | head -n 1) + nix log $o +fi + -- cgit v1.2.3