diff --git a/mitamae/.gitignore b/mitamae/.gitignore new file mode 100644 index 0000000..6c0c2d1 --- /dev/null +++ b/mitamae/.gitignore @@ -0,0 +1,2 @@ +# Downloaded mitamae binary +bin/ diff --git a/mitamae/bootstrap.sh b/mitamae/bootstrap.sh new file mode 100755 index 0000000..520d391 --- /dev/null +++ b/mitamae/bootstrap.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +# bootstrap.sh — download mitamae and run the package recipe +# +# Usage: ./mitamae/bootstrap.sh +# +# Downloads the mitamae binary for the current platform from GitHub releases, +# then runs recipe.rb to install packages. + +set -euo pipefail + +MITAMAE_VERSION="v1.14.4" +MITAMAE_DIR="$(cd "$(dirname "$0")" && pwd)" +MITAMAE_BIN="${MITAMAE_DIR}/bin/mitamae" + +# --- Detect platform --- +detect_platform() { + local os arch + + case "$(uname -s)" in + Darwin) os="darwin" ;; + Linux) os="linux" ;; + *) + echo "Unsupported OS: $(uname -s)" >&2 + exit 1 + ;; + esac + + case "$(uname -m)" in + x86_64|amd64) arch="x86_64" ;; + aarch64|arm64) arch="aarch64" ;; + *) + echo "Unsupported architecture: $(uname -m)" >&2 + exit 1 + ;; + esac + + echo "${arch}-${os}" +} + +# --- Download mitamae --- +download_mitamae() { + if [[ -x "${MITAMAE_BIN}" ]]; then + local current_version + current_version=$("${MITAMAE_BIN}" version 2>/dev/null || echo "unknown") + if [[ "${current_version}" == *"${MITAMAE_VERSION#v}"* ]]; then + echo "✓ mitamae ${MITAMAE_VERSION} already installed" + return + fi + fi + + local platform + platform="$(detect_platform)" + local url="https://github.com/itamae-kitchen/mitamae/releases/download/${MITAMAE_VERSION}/mitamae-${platform}" + + echo "→ Downloading mitamae ${MITAMAE_VERSION} for ${platform}..." + mkdir -p "${MITAMAE_DIR}/bin" + curl -fsSL -o "${MITAMAE_BIN}" "${url}" + chmod +x "${MITAMAE_BIN}" + echo "✓ mitamae installed to ${MITAMAE_BIN}" +} + +# --- Main --- +echo "" +echo " mitamae bootstrap" +echo " =================" +echo "" + +download_mitamae + +echo "" +echo "→ Running recipe..." +echo "" + +exec "${MITAMAE_BIN}" local "${MITAMAE_DIR}/recipe.rb" diff --git a/mitamae/recipe.rb b/mitamae/recipe.rb new file mode 100644 index 0000000..16046a7 --- /dev/null +++ b/mitamae/recipe.rb @@ -0,0 +1,55 @@ +# recipe.rb — cross-platform package installation +# +# Uses mitamae's `package` resource which auto-detects the package manager: +# - Homebrew on macOS +# - apt on Debian/Ubuntu Linux +# +# Run via: mitamae local recipe.rb + +# --- Helpers --- +def macos? + node[:platform] == "darwin" +end + +def linux? + node[:platform] == "linux" +end + +# --- Core packages --- +# These are needed on all platforms. + +package "neovim" do + not_if "which nvim" +end + +package "gh" do + not_if "which gh" +end + +package "tmux" do + not_if "which tmux" +end + +package "ripgrep" do + not_if "which rg" +end + +package "fzf" do + not_if "which fzf" +end + +# --- mise (polyglot version manager) --- +# mise isn't in most distro repos, so install via its official script. +execute "install mise" do + command "curl -fsSL https://mise.jdx.dev/install.sh | sh" + not_if "which mise" +end + +# --- macOS-only packages --- +if macos? + # Ghostty is distributed as a macOS app (brew cask) + execute "install ghostty" do + command "brew install --cask ghostty" + not_if "brew list --cask ghostty >/dev/null 2>&1" + end +end