#!/usr/bin/env bash

# Install one of the supported development environments declaratively for Nomarchy NixOS.

if [[ -z $1 ]]; then
  echo "Usage: nomarchy-install-dev-env <ruby|node|bun|deno|go|laravel|symfony|php|python|elixir|phoenix|rust|java|zig|ocaml|dotnet|clojure|scala>" >&2
  exit 1
fi

case "$1" in
php)
  echo -e "Installing PHP and extensions declaratively...\n"
  # This uses the already refactored declarative nomarchy-pkg-add
  nomarchy-pkg-add php
  nomarchy-pkg-add phpExtensions.bcmath
  nomarchy-pkg-add phpExtensions.intl
  nomarchy-pkg-add phpExtensions.iconv
  nomarchy-pkg-add phpExtensions.openssl
  nomarchy-pkg-add phpExtensions.pdo_sqlite
  nomarchy-pkg-add phpExtensions.pdo_mysql
  nomarchy-pkg-add phpPackages.composer
  echo -e "\nPHP environment added to your packages."
  ;;
# The rest use 'mise' which is already installed and manages its own state in ~/.config/mise
*)
  # Delegate to the original script logic if mise is used
  # Or we can just call the mise command directly if it's a simple case.
  # Let's keep the mise-based language installs as they are, but make sure mise is available.
  /etc/profiles/per-user/$USER/bin/nomarchy-install-dev-env.original "$@"
  ;;
esac
