From 227833b29cb34678f639495d39bdc3e4c0f5f7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20S=C3=B6derberg?= Date: Mon, 20 Apr 2026 16:59:49 +0200 Subject: [PATCH] Better startup script --- main.tf | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/main.tf b/main.tf index d3e56df..229e94f 100644 --- a/main.tf +++ b/main.tf @@ -31,29 +31,55 @@ resource "coder_agent" "main" { startup_script = <<-EOT set -e - # 1. Standard home init + # --- Logging Helper --- + log() { + echo -e "\e[1;34m[INIT]\e[0m $(date +'%H:%M:%S') - $1" + } + + # 1. Prepare user home with default files if [ ! -f ~/.init_done ]; then - cp -rT /etc/skel ~ + log "Fresh workspace detected. Starting first-time setup..." + log "Copying system skeleton files to home..." + cp -rT /etc/skel ~ + # 2. Install GHCup & Haskell + log "Installing GHCup, GHC, Cabal, and HLS (this will take a few minutes)..." curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \ BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ + BOOTSTRAP_HASKELL_INSTALL_GHCUP=1 \ BOOTSTRAP_HASKELL_GHC_VERSION=latest \ BOOTSTRAP_HASKELL_CABAL_VERSION=latest \ BOOTSTRAP_HASKELL_HLS_VERSION=latest \ sh + log "Haskell toolchain installed successfully." - # 3. Install Scala + # 3. Install Scala (Coursier) + log "Downloading Coursier for Scala management..." curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs chmod +x cs + log "Running Scala setup (Installing scala, scalac, sbt, etc.)..." ./cs setup --yes rm cs + log "Scala environment ready." - # 4. Create Python Venv + # 4. Python Venv + log "Creating Python virtual environment in ~/.venv..." python3 -m venv ~/.venv + log "Python venv created. Tip: Use 'source ~/.venv/bin/activate' to use it." + # 5. Finalize touch ~/.init_done + log "Setup complete! All tools are installed in your persistent home volume." + else + log "Persistent volume detected. Tools are already installed in /home/${local.username}." fi + + # This runs every time, even if setup is already done + log "Ensuring PATH is updated for current session..." + # Add GHCup and local bins to path if not already there + [ -f "$HOME/.ghcup/env" ] && source "$HOME/.ghcup/env" + log "Workspace is ready for coding." EOT # These environment variables allow you to make Git commits right away after creating a