Files
connector-popos/configure.d/40-languages.sh
T
davidandClaude Opus 5.5 bc07e1d3e3 Set up Pop!_OS for a Federated Core, like CoreDesktop's configure
A port of CoreDesktop's configure to Pop!_OS 24.04 with COSMIC, in the shape
of connector-macos: its own install.sh, update and configure, installed in
~/.local/share/federated-connector/connector.

Every configure item is ported: the Core (email, calendars and contacts
through GNOME Online Accounts and Evolution, as COSMIC has no accounts of its
own; Superpanel; files over davfs2; Element; Tally; the email watcher),
Tailscale, backups, AI agents in the sandbox and their sign-ins, languages
with mise, AI servers, printers, network storage and the agent sandbox.
Folders go in the COSMIC Files sidebar. Each item installs what it needs
from apt, Flathub or the tool's own apt repository when you set it up.

smoketest/run checks it in Ubuntu 24.04 containers with Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:20:47 -07:00

99 lines
3.4 KiB
Bash

#!/bin/bash
# configure reads TITLE and DESCRIPTION
# shellcheck disable=SC2034
TITLE="Languages"
# shellcheck disable=SC2034
DESCRIPTION="Install programming languages with mise, e.g. Ruby on Rails"
# Records that you've chosen, even if you chose nothing, so this isn't "to do"
LANGUAGES_CONF="$CONF_DIR/languages"
# mise installs these gems into each Ruby it installs, so Rails is still there
# after mise upgrade moves to a new Ruby
DEFAULT_GEMS="$HOME/.default-gems"
# mise's activation line goes in ~/.bashrc, so the languages it installs are
# on PATH in new terminals
BASHRC="$HOME/.bashrc"
BLOCK_START="# >>> Federated Connector: mise >>>"
BLOCK_END="# <<< Federated Connector: mise <<<"
# Ruby is built from source, which needs these (from ruby-build's wiki)
RUBY_BUILD_DEPS=(build-essential autoconf patch rustc libssl-dev libyaml-dev libreadline-dev
zlib1g-dev libgmp-dev libncurses-dev libffi-dev libgdbm-dev libdb-dev uuid-dev)
is_configured() {
[ -f "$LANGUAGES_CONF" ]
}
# Add a gem to ~/.default-gems unless it's there
add_default_gem() {
grep -qsx "$1" "$DEFAULT_GEMS" || echo "$1" >> "$DEFAULT_GEMS"
}
# From mise's own apt repository, so Pop!_OS' updates keep mise up to date
install_mise() {
echo "mise isn't installed. It comes from mise's own apt repository (mise.jdx.dev)."
confirm_yes "Install it?" || return 1
sudo install -dm 755 /etc/apt/keyrings || return 1
curl -fsSL --max-time 60 https://mise.jdx.dev/gpg-key.pub \
| sudo tee /etc/apt/keyrings/mise-archive-keyring.asc > /dev/null || return 1
echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.asc] https://mise.jdx.dev/deb stable main" \
| sudo tee /etc/apt/sources.list.d/mise.list > /dev/null || return 1
sudo apt-get update && sudo apt-get install -y mise
}
activated() {
grep -qsxF "$BLOCK_START" "$BASHRC"
}
activate() {
{
echo
echo "$BLOCK_START"
echo "# The languages configure languages installs: see mise ls"
echo 'eval "$(mise activate bash)"'
echo "$BLOCK_END"
} >> "$BASHRC" || return 1
echo "Added mise to ~/.bashrc; the languages it installs work in new terminals."
}
install_rails() {
pkg_ensure "Building Ruby" "${RUBY_BUILD_DEPS[@]}" || return 1
echo "Installing Ruby and Rails..."
add_default_gem bundler || return 1
add_default_gem rails || return 1
mise use -g ruby@latest || return 1
# Ruby may already have been installed before ~/.default-gems listed these
mise exec -- gem install --conservative bundler rails || return 1
grep -qsx rails "$LANGUAGES_CONF" || echo rails >> "$LANGUAGES_CONF"
}
run_configure() {
local tools tool
export MISE_YES=1
# From home, so a project's mise.toml in the current directory doesn't count
cd "$HOME" || return 1
echo "mise installs programming languages and tools for you, and the version a"
echo "project asks for in its mise.toml."
command -v mise > /dev/null || install_mise || return 1
activated || activate || return 1
mkdir -p "$(dirname "$LANGUAGES_CONF")"
touch "$LANGUAGES_CONF" || return 1
if confirm "Install Ruby on Rails?"; then
install_rails || return 1
fi
echo "Anything else? Name tools mise knows (mise registry lists them), with a version,"
read -rp "e.g. node@lts python@3.13 go@latest, or press Enter for none: " tools
for tool in $tools; do
echo "Installing $tool..."
mise use -g "$tool" || return 1
done
echo "To update them: mise upgrade. To remove one later: mise unuse -g <tool>"
}