Better startup script

This commit is contained in:
2026-04-20 16:59:49 +02:00 Verified
parent 997f86761a
commit 227833b29c
+30 -4
View File
@@ -31,29 +31,55 @@ resource "coder_agent" "main" {
startup_script = <<-EOT startup_script = <<-EOT
set -e 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 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 # 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 | \ curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
BOOTSTRAP_HASKELL_INSTALL_GHCUP=1 \
BOOTSTRAP_HASKELL_GHC_VERSION=latest \ BOOTSTRAP_HASKELL_GHC_VERSION=latest \
BOOTSTRAP_HASKELL_CABAL_VERSION=latest \ BOOTSTRAP_HASKELL_CABAL_VERSION=latest \
BOOTSTRAP_HASKELL_HLS_VERSION=latest \ BOOTSTRAP_HASKELL_HLS_VERSION=latest \
sh 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 curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs
chmod +x cs chmod +x cs
log "Running Scala setup (Installing scala, scalac, sbt, etc.)..."
./cs setup --yes ./cs setup --yes
rm cs rm cs
log "Scala environment ready."
# 4. Create Python Venv # 4. Python Venv
log "Creating Python virtual environment in ~/.venv..."
python3 -m venv ~/.venv python3 -m venv ~/.venv
log "Python venv created. Tip: Use 'source ~/.venv/bin/activate' to use it."
# 5. Finalize
touch ~/.init_done 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 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 EOT
# These environment variables allow you to make Git commits right away after creating a # These environment variables allow you to make Git commits right away after creating a