From 0061fae2e6fd62f6d2a76418b62815bd49add51c Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <edolstra@gmail.com>
Date: Thu, 7 Sep 2017 22:24:27 +0200
Subject: [PATCH] genericBuild: Communicate the current build phase to Nix

This allows the progress bar to show e.g.

  [1/9/59 built] building bison-3.0.4 (configurePhase): checking for strdup... yes
---
 pkgs/stdenv/generic/setup.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index 8a000091491d..ce8c3ecef829 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -1016,6 +1016,10 @@ genericBuild() {
         if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then continue; fi
         if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then continue; fi
 
+        if [[ -n $NIX_LOG_FD ]]; then
+            echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" >&$NIX_LOG_FD
+        fi
+
         showPhaseHeader "$curPhase"
         dumpVars