Files
inter-hub/scripts/compile-check
tegwick 7972b38820
Some checks failed
Test / test (push) Has been cancelled
feat(build): tune GHC for haskelseed (8 CPU / 30 GiB)
- .ghci: -j1 → -j4 for parallel module compilation
- scripts/compile-check: auto-detect high-RAM hosts (>16GB) and
  set GHCRTS="-A256m -M20g" to reduce GC pressure
- devenv.nix: update comment only (GHCRTS still set at runtime)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 01:32:36 +02:00

49 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# scripts/compile-check — one-shot GHC compilation check.
#
# Does NOT start postgres or tailwind — just GHC.
# Relies on .ghci (sets -j4, -fkeep-going, loads IHP config).
#
# Usage:
# scripts/compile-check # show errors in terminal + write log
# scripts/compile-check --bg # write log only (for background/Claude use)
#
# Can be invoked via nix develop:
# nix develop --override-input devenv-root "file+file://$PWD/.devenv/root" \
# --command scripts/compile-check --bg
#
# Log file: /tmp/ihub-compile-errors.txt (override with IHUB_COMPILE_LOG)
set -euo pipefail
LOGFILE="${IHUB_COMPILE_LOG:-/tmp/ihub-compile-errors.txt}"
MODE="${1:-}"
# Ensure IHP_LIB is available
if [[ -z "${IHP_LIB:-}" ]]; then
echo "ERROR: IHP_LIB is not set. Run inside devenv shell or via nix develop." >&2
exit 1
fi
: > "$LOGFILE"
echo "[compile-check] Log: $LOGFILE"
echo "[compile-check] Mode: ${MODE:-interactive}"
echo "[compile-check] IHP_LIB: $IHP_LIB"
# Override GHC RTS for hosts with more RAM (e.g., haskelseed: 8 CPU / 30 GiB).
# devenv.nix sets -M2g for constrained hosts; override here if available RAM is higher.
TOTAL_RAM_MB=$(awk '/MemTotal/{print int($2/1024)}' /proc/meminfo 2>/dev/null || echo 0)
if [[ "$TOTAL_RAM_MB" -gt 16000 ]]; then
export GHCRTS="-A256m -M20g"
echo "[compile-check] Host RAM: ${TOTAL_RAM_MB}MB — using GHCRTS=$GHCRTS"
fi
# One-shot compile: load all modules via .ghci config then quit immediately.
# -fkeep-going (set in .ghci) ensures all errors are reported, not just the first.
# ghcid is not available in this environment; ghci one-shot gives the same error output.
if [[ "$MODE" == "--bg" ]]; then
echo ':quit' | ghci 2>&1 | tee "$LOGFILE"
else
echo ':quit' | ghci 2>&1 | tee "$LOGFILE"
fi