diff --git a/020_mise.sh b/020_mise.sh index 9ff6db2..1c8479d 100644 --- a/020_mise.sh +++ b/020_mise.sh @@ -1,24 +1,33 @@ #!/usr/bin/env bash - +# # a development environment setup tool. sudo apt update -qq && sudo apt install -y curl # sudo install -dm 755 /etc/apt/keyrings DEST=${1:-/etc/skel} -URI="https://mise.jdx.dev" + +URI="mise.jdx.dev" +TRANSPORT="https:/" +TYPES=(deb) +SUITES="stable" +COMPONENTS=(main) +ARCHITECTURES=(amd64) KEY_DIR="/usr/share/keyrings" -KEY="${KEY_DIR}/mise-archive-keyring.asc" +KEY="${KEY_DIR}/mise-archive-keyring.gpg" MISE_HOME="${DEST}/.config/mise" MISE_CONFIG_DIR="${MISE_HOME}/conf.d" +mkdir -p "${MISE_CONFIG_DIR}" -curl -fSs ${URI}/gpg-key.pub | sudo tee ${KEY} 1>/dev/null +curl -fSs ${TRANSPORT}/${URI}/gpg-key.pub | sudo gpg --dearmor --yes -o ${KEY} 1>/dev/null conf_print_sources() { cat <"$temp_config"; then + echo "Error: Provider command failed. Keeping existing config." + rm -f "$temp_config" + return 1 + fi + + # 3. Rotate existing config if it exists + if [[ -f "$target_file" ]]; then + echo "Backing up $(basename "$target_file") to .backups/..." + mv "$target_file" "${backup_dir}/$(basename "$target_file").${timestamp}.bak" + fi + + # 4. Move new config into place + mv "$temp_config" "$target_file" + echo "New config written to $target_file" + + # 5. Cleanup + find "$backup_dir" -name "*.bak" -type f -mtime +"$retention_days" -delete +} + +# Have mise activated by zsh echo "eval $(/usr/bin/mise activate zsh)" >"${DEST}/.zshrc.d/004_mise.zsh" -if [[ -f ${MISE_HOME}/mise.toml ]]; then - conf_print_mise_config() { - cat < + +# Example if your environment is named 'my-data-env' +# mise use python@prefix:~/anaconda3/envs/my-data-env +# mise use python@prefix:${CONDA_ENVS_DIR}/my-data-env +# mise use node@prefix:${CONDA_ENVS_DIR}/node_env +# mise use go@prefix:${CONDA_ENVS_DIR}/goenv + +conf_print_mise_config() { + cat <