{ pkgs
}:

pkgs.chromium.passthru.browser.overrideAttrs (old: {
  pname = "cultguard-chromium-first-compile-smoke";

  buildPhase = ''
    export SCCACHE_WRAPPER_LOG="''${SCCACHE_WRAPPER_LOG:-$TMPDIR/sccache-wrapper.log}"
    rm -f "$SCCACHE_WRAPPER_LOG"
    if [ -n "''${SCCACHE_WRAPPER_STRACE:-}" ]; then
      rm -f "$SCCACHE_WRAPPER_STRACE"
    fi

    printf 'uid=%s gid=%s groups=%s\n' "$(id -u)" "$(id -g)" "$(id -Gn)"
    printf 'PATH=%s\n' "$PATH"
    printf 'clang++=%s\n' "$(command -v clang++)"
    printf 'wrapper=%s\n' "${pkgs.cultguardSccacheWrapper}/bin/cultguard-sccache-wrapper"
    printf 'sccache_server_uds=%s\n' "''${SCCACHE_SERVER_UDS:-}"
    printf 'sccache_conf=%s\n' "''${SCCACHE_CONF:-}"

    set +e
    ninja -C out/Release -j1 -v obj/buildtools/third_party/libc++abi/libc++abi/abort_message.o
    status=$?
    set -e

    echo '--- sccache stats ---'
    ${pkgs.sccache}/bin/sccache --show-stats || true
    echo '--- wrapper log ---'
    cat "$SCCACHE_WRAPPER_LOG" || true
    if [ -n "''${SCCACHE_WRAPPER_STRACE:-}" ]; then
      echo '--- wrapper strace tail ---'
      tail -n 200 "$SCCACHE_WRAPPER_STRACE" || true
    fi

    mkdir -p "$out"
    if [ -n "''${sandbox:-}" ]; then
      mkdir -p "$sandbox"
    fi
    exit "$status"
  '';
})
