#!/bin/bash # Ubuntu Development Environment Module ubuntu_install_rust() { log SECTION "Installing Rust toolchain" local section_start=$(date +%s) if confirm "Install Rust via rustup?"; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path -y if [ "${SYSTEM_INFO[WSL]}" == "yes" ]; then source "$HOME/.cargo/env" fi rustup self update rustup update stable rustup default stable log SUCCESS "Rust installed $(show_timer $section_start)" fi } ubuntu_install_node() { log SECTION "Installing Node.js" local section_start=$(date +%s) if confirm "Install Node.js?"; then curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - install_packages nodejs npm config set prefix "${HOME}/.npm" log SUCCESS "Node.js installed $(show_timer $section_start)" fi } ubuntu_install_python() { log SECTION "Setting up Python development" local section_start=$(date +%s) local version="${SYSTEM_INFO[VERSION]}" if [ "$version" == "22.04" ]; then pip3 install pynvim else install_packages python3-pynvim fi log SUCCESS "Python development setup $(show_timer $section_start)" } ubuntu_build_neovim() { if ! role_enabled "CODE" && ! role_enabled "DEVELOPMENT"; then return 0 fi log SECTION "Building Neovim from source" local section_start=$(date +%s) if confirm "Build Neovim from source?"; then # Remove system neovim if in WSL if [ "${SYSTEM_INFO[WSL]}" == "yes" ]; then sudo apt -y purge --auto-remove neovim fi install_packages bat fd-find cd ~ if [ -d ~/neovim ]; then rm -rf ~/neovim; fi ( git clone https://github.com/neovim/neovim cd neovim && git checkout stable make CMAKE_BUILD_TYPE=RelWithDebInfo cd build && cpack -G DEB && sudo dpkg -i nvim*.deb ) 2>&1 | tee -a "$LOG_FILE" & spinner $! "Building Neovim (this will take a while)..." wait if [ -d ~/neovim ]; then rm -rf ~/neovim; fi mkdir -p ~/.config/nvim ln -sf ~/linuxbox/config/nvim/init.lua ~/.config/nvim/init.lua log SUCCESS "Neovim built and installed $(show_timer $section_start)" fi } ubuntu_install_languages() { log SECTION "Installing programming languages" local section_start=$(date +%s) if confirm "Install additional languages (Go, PHP, Ruby, etc.)?"; then local packages=(golang ruby ruby-dev php php-curl php-xml php-mbstring luarocks composer) install_packages "${packages[@]}" # Java installation if [ "${SYSTEM_INFO[WSL]}" == "yes" ]; then sudo add-apt-repository -y ppa:linuxuprising/java sudo apt update install_packages oracle-java17-installer else install_packages default-jdk fi log SUCCESS "Programming languages installed $(show_timer $section_start)" fi } ubuntu_install_julia() { if ! role_enabled "CODE" && ! role_enabled "DEVELOPMENT"; then return 0 fi log SECTION "Installing Julia" local section_start=$(date +%s) if confirm "Install Julia programming language?"; then cd ~ wget https://julialang-s3.julialang.org/bin/linux/x64/1.9/julia-1.9.0-linux-x86_64.tar.gz tar -xvzf julia-1.9.0-linux-x86_64.tar.gz sudo cp -r julia-1.9.0 /opt/ sudo ln -sf /opt/julia-1.9.0/bin/julia /usr/local/bin/julia rm julia-1.9.0-linux-x86_64.tar.gz* rm -rf julia-1.9.0 log SUCCESS "Julia installed $(show_timer $section_start)" fi } ubuntu_setup_development() { if ! role_enabled "CODE" && ! role_enabled "DEVELOPMENT"; then return 0 fi ubuntu_install_rust ubuntu_install_node ubuntu_install_python ubuntu_build_neovim ubuntu_install_languages ubuntu_install_julia } if [ -z "$UBUNTU_DEVELOPMENT_LOADED" ]; then UBUNTU_DEVELOPMENT_LOADED=true fi