diff options
author | Ben Sima <ben@bsima.me> | 2020-06-17 15:31:55 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-06-17 15:31:55 -0700 |
commit | 8b784c24b1190ed5ea35b699152d43c61481302f (patch) | |
tree | 91e5fa62dd8bda495cd4f9afc3efbc8ff2843102 /bild | |
parent | de70e6455ae735a9d24e00677a07dbaf2b6cf355 (diff) |
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.
Diffstat (limited to 'bild')
-rwxr-xr-x | bild | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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 + |