this repo has no description

install mise via nix

altagos.dev f41c3e89 13f4199a

verified
+1 -340
+1 -3
.tangled/workflows/build.yml
··· 1 1 when: 2 2 - event: ["push", "pull_request"] 3 3 branch: ["main", "workflows"] 4 - - event: ["manual"] 5 4 6 5 engine: nixery 7 6 ··· 9 8 nixpkgs: 10 9 - curl 11 10 - dart-sass 12 - - gnugrep 13 - - gnutar 11 + - mise 14 12 - zip 15 13 16 14 environment:
-337
bin/mise
··· 1 - #!/usr/bin/env bash 2 - set -eu 3 - 4 - __mise_bootstrap() { 5 - local project_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && cd .. && pwd ) 6 - local localized_dir="$project_dir/.mise" 7 - export MISE_DATA_DIR="$localized_dir" 8 - export MISE_CONFIG_DIR="$localized_dir" 9 - export MISE_CACHE_DIR="$localized_dir/cache" 10 - export MISE_STATE_DIR="$localized_dir/state" 11 - export MISE_INSTALL_PATH="$localized_dir/mise-2025.11.11" 12 - export MISE_TRUSTED_CONFIG_PATHS="$project_dir${MISE_TRUSTED_CONFIG_PATHS:+:$MISE_TRUSTED_CONFIG_PATHS}" 13 - export MISE_IGNORED_CONFIG_PATHS="$HOME/.config/mise${MISE_IGNORED_CONFIG_PATHS:+:$MISE_IGNORED_CONFIG_PATHS}" 14 - install() { 15 - local initial_working_dir="$PWD" 16 - #!/bin/sh 17 - set -eu 18 - 19 - #region logging setup 20 - if [ "${MISE_DEBUG-}" = "true" ] || [ "${MISE_DEBUG-}" = "1" ]; then 21 - debug() { 22 - echo "$@" >&2 23 - } 24 - else 25 - debug() { 26 - : 27 - } 28 - fi 29 - 30 - if [ "${MISE_QUIET-}" = "1" ] || [ "${MISE_QUIET-}" = "true" ]; then 31 - info() { 32 - : 33 - } 34 - else 35 - info() { 36 - echo "$@" >&2 37 - } 38 - fi 39 - 40 - error() { 41 - echo "$@" >&2 42 - exit 1 43 - } 44 - #endregion 45 - 46 - #region environment setup 47 - get_os() { 48 - os="$(uname -s)" 49 - if [ "$os" = Darwin ]; then 50 - echo "macos" 51 - elif [ "$os" = Linux ]; then 52 - echo "linux" 53 - else 54 - error "unsupported OS: $os" 55 - fi 56 - } 57 - 58 - get_arch() { 59 - musl="" 60 - if type ldd >/dev/null 2>/dev/null; then 61 - if [ "${MISE_INSTALL_MUSL-}" = "1" ] || [ "${MISE_INSTALL_MUSL-}" = "true" ]; then 62 - musl="-musl" 63 - elif [ "$(uname -o)" = "Android" ]; then 64 - # Android (Termux) always uses musl 65 - musl="-musl" 66 - else 67 - libc=$(ldd /bin/ls | grep 'musl' | head -1 | cut -d ' ' -f1) 68 - if [ -n "$libc" ]; then 69 - musl="-musl" 70 - fi 71 - fi 72 - fi 73 - arch="$(uname -m)" 74 - if [ "$arch" = x86_64 ]; then 75 - echo "x64$musl" 76 - elif [ "$arch" = aarch64 ] || [ "$arch" = arm64 ]; then 77 - echo "arm64$musl" 78 - elif [ "$arch" = armv7l ]; then 79 - echo "armv7$musl" 80 - else 81 - error "unsupported architecture: $arch" 82 - fi 83 - } 84 - 85 - get_ext() { 86 - if [ -n "${MISE_INSTALL_EXT:-}" ]; then 87 - echo "$MISE_INSTALL_EXT" 88 - elif [ -n "${MISE_VERSION:-}" ] && echo "$MISE_VERSION" | grep -q '^v2024'; then 89 - # 2024 versions don't have zstd tarballs 90 - echo "tar.gz" 91 - elif tar_supports_zstd; then 92 - echo "tar.zst" 93 - elif command -v zstd >/dev/null 2>&1; then 94 - echo "tar.zst" 95 - else 96 - echo "tar.gz" 97 - fi 98 - } 99 - 100 - tar_supports_zstd() { 101 - # tar is bsdtar or version is >= 1.31 102 - if tar --version | grep -q 'bsdtar' && command -v zstd >/dev/null 2>&1; then 103 - true 104 - elif tar --version | grep -q '1\.(3[1-9]|[4-9][0-9]'; then 105 - true 106 - else 107 - false 108 - fi 109 - } 110 - 111 - shasum_bin() { 112 - if command -v shasum >/dev/null 2>&1; then 113 - echo "shasum" 114 - elif command -v sha256sum >/dev/null 2>&1; then 115 - echo "sha256sum" 116 - else 117 - error "mise install requires shasum or sha256sum but neither is installed. Aborting." 118 - fi 119 - } 120 - 121 - get_checksum() { 122 - version=$1 123 - os=$2 124 - arch=$3 125 - ext=$4 126 - url="https://github.com/jdx/mise/releases/download/v${version}/SHASUMS256.txt" 127 - 128 - # For current version use static checksum otherwise 129 - # use checksum from releases 130 - if [ "$version" = "v2025.11.11" ]; then 131 - checksum_linux_x86_64="f1ba51b26998d5d75fe14c74e16f8a66a13bf2a403f5ca97e3efb1f952ee5bf7 ./mise-v2025.11.11-linux-x64.tar.gz" 132 - checksum_linux_x86_64_musl="b3d0ada98b5319ca9e1095d8761ab10c8854fdd5c7487e85cbb7e6972a69ffea ./mise-v2025.11.11-linux-x64-musl.tar.gz" 133 - checksum_linux_arm64="2d9e3e27da8323d331ed01c0424dfc282856c1124626eb3f1ad79a1588e33763 ./mise-v2025.11.11-linux-arm64.tar.gz" 134 - checksum_linux_arm64_musl="502059f4c449e7a18f4994ceba8c91c27f05364bb80b14c51f19be03a8f267d0 ./mise-v2025.11.11-linux-arm64-musl.tar.gz" 135 - checksum_linux_armv7="2be7aec10ec9a79fcede2b930fcfbf1a5e755900a4861c01ba4a3ceef2d516a8 ./mise-v2025.11.11-linux-armv7.tar.gz" 136 - checksum_linux_armv7_musl="293c94b0cedf2fb53c6fea7f7149e2217d53c0dddb6aea1692c56c6bbcb3159f ./mise-v2025.11.11-linux-armv7-musl.tar.gz" 137 - checksum_macos_x86_64="c64c00028db0bbb73d4a9801a2ecb68f9cf5927c4e53740871e5d7ba8ab0b3c7 ./mise-v2025.11.11-macos-x64.tar.gz" 138 - checksum_macos_arm64="afbf065a2759dcbee8fc56b7afa0324c5f76e09b7bac245284a5f8b8d4bb1d81 ./mise-v2025.11.11-macos-arm64.tar.gz" 139 - checksum_linux_x86_64_zstd="9fefbbef115f9dad3ed3068edd52bcdd27a04d4829a63d4917ddd20c14367c11 ./mise-v2025.11.11-linux-x64.tar.zst" 140 - checksum_linux_x86_64_musl_zstd="59e9267bb388784ff17dbf99104e1d8f03aaafae6e84e4eeb8437ebe683b27a3 ./mise-v2025.11.11-linux-x64-musl.tar.zst" 141 - checksum_linux_arm64_zstd="3d6242e5296292a1aa4d42cfd8631ef12a3cf9f3c7cc5eb39a102896d93e0784 ./mise-v2025.11.11-linux-arm64.tar.zst" 142 - checksum_linux_arm64_musl_zstd="2f4116d30bd99e3eb9b3fe949c02d46d99339d3e573bd824ecd0185a69367275 ./mise-v2025.11.11-linux-arm64-musl.tar.zst" 143 - checksum_linux_armv7_zstd="f00100833cc08aa854b2af77dd559191cc1c7d54a32ff8121170dbc8c965e62b ./mise-v2025.11.11-linux-armv7.tar.zst" 144 - checksum_linux_armv7_musl_zstd="96afb1ccc771b7310f870a1df7699f9601da0fe5083fbb0a0f760ecbe66a697c ./mise-v2025.11.11-linux-armv7-musl.tar.zst" 145 - checksum_macos_x86_64_zstd="f5ffcf4c2263bcdce78ae5344f4ccc4bbf0e93f7619799cac140079a50bbb37a ./mise-v2025.11.11-macos-x64.tar.zst" 146 - checksum_macos_arm64_zstd="c07ca98edb30062879b47e5eb46f31d86b71cbd88f62d3350236178e5a8552a9 ./mise-v2025.11.11-macos-arm64.tar.zst" 147 - 148 - # TODO: refactor this, it's a bit messy 149 - if [ "$ext" = "tar.zst" ]; then 150 - if [ "$os" = "linux" ]; then 151 - if [ "$arch" = "x64" ]; then 152 - echo "$checksum_linux_x86_64_zstd" 153 - elif [ "$arch" = "x64-musl" ]; then 154 - echo "$checksum_linux_x86_64_musl_zstd" 155 - elif [ "$arch" = "arm64" ]; then 156 - echo "$checksum_linux_arm64_zstd" 157 - elif [ "$arch" = "arm64-musl" ]; then 158 - echo "$checksum_linux_arm64_musl_zstd" 159 - elif [ "$arch" = "armv7" ]; then 160 - echo "$checksum_linux_armv7_zstd" 161 - elif [ "$arch" = "armv7-musl" ]; then 162 - echo "$checksum_linux_armv7_musl_zstd" 163 - else 164 - warn "no checksum for $os-$arch" 165 - fi 166 - elif [ "$os" = "macos" ]; then 167 - if [ "$arch" = "x64" ]; then 168 - echo "$checksum_macos_x86_64_zstd" 169 - elif [ "$arch" = "arm64" ]; then 170 - echo "$checksum_macos_arm64_zstd" 171 - else 172 - warn "no checksum for $os-$arch" 173 - fi 174 - else 175 - warn "no checksum for $os-$arch" 176 - fi 177 - else 178 - if [ "$os" = "linux" ]; then 179 - if [ "$arch" = "x64" ]; then 180 - echo "$checksum_linux_x86_64" 181 - elif [ "$arch" = "x64-musl" ]; then 182 - echo "$checksum_linux_x86_64_musl" 183 - elif [ "$arch" = "arm64" ]; then 184 - echo "$checksum_linux_arm64" 185 - elif [ "$arch" = "arm64-musl" ]; then 186 - echo "$checksum_linux_arm64_musl" 187 - elif [ "$arch" = "armv7" ]; then 188 - echo "$checksum_linux_armv7" 189 - elif [ "$arch" = "armv7-musl" ]; then 190 - echo "$checksum_linux_armv7_musl" 191 - else 192 - warn "no checksum for $os-$arch" 193 - fi 194 - elif [ "$os" = "macos" ]; then 195 - if [ "$arch" = "x64" ]; then 196 - echo "$checksum_macos_x86_64" 197 - elif [ "$arch" = "arm64" ]; then 198 - echo "$checksum_macos_arm64" 199 - else 200 - warn "no checksum for $os-$arch" 201 - fi 202 - else 203 - warn "no checksum for $os-$arch" 204 - fi 205 - fi 206 - else 207 - if command -v curl >/dev/null 2>&1; then 208 - debug ">" curl -fsSL "$url" 209 - checksums="$(curl --compressed -fsSL "$url")" 210 - else 211 - if command -v wget >/dev/null 2>&1; then 212 - debug ">" wget -qO - "$url" 213 - checksums="$(wget -qO - "$url")" 214 - else 215 - error "mise standalone install specific version requires curl or wget but neither is installed. Aborting." 216 - fi 217 - fi 218 - # TODO: verify with minisign or gpg if available 219 - 220 - checksum="$(echo "$checksums" | grep "$os-$arch.$ext")" 221 - if ! echo "$checksum" | grep -Eq "^([0-9a-f]{32}|[0-9a-f]{64})"; then 222 - warn "no checksum for mise $version and $os-$arch" 223 - else 224 - echo "$checksum" 225 - fi 226 - fi 227 - } 228 - 229 - #endregion 230 - 231 - download_file() { 232 - url="$1" 233 - download_dir="$2" 234 - filename="$(basename "$url")" 235 - file="$download_dir/$filename" 236 - 237 - info "mise: installing mise..." 238 - 239 - if command -v curl >/dev/null 2>&1; then 240 - debug ">" curl -#fLo "$file" "$url" 241 - curl -#fLo "$file" "$url" 242 - else 243 - if command -v wget >/dev/null 2>&1; then 244 - debug ">" wget -qO "$file" "$url" 245 - stderr=$(mktemp) 246 - wget -O "$file" "$url" >"$stderr" 2>&1 || error "wget failed: $(cat "$stderr")" 247 - rm "$stderr" 248 - else 249 - error "mise standalone install requires curl or wget but neither is installed. Aborting." 250 - fi 251 - fi 252 - 253 - echo "$file" 254 - } 255 - 256 - install_mise() { 257 - version="${MISE_VERSION:-v2025.11.11}" 258 - version="${version#v}" 259 - os="${MISE_INSTALL_OS:-$(get_os)}" 260 - arch="${MISE_INSTALL_ARCH:-$(get_arch)}" 261 - ext="${MISE_INSTALL_EXT:-$(get_ext)}" 262 - install_path="${MISE_INSTALL_PATH:-$HOME/.local/bin/mise}" 263 - install_dir="$(dirname "$install_path")" 264 - install_from_github="${MISE_INSTALL_FROM_GITHUB:-}" 265 - if [ "$version" != "v2025.11.11" ] || [ "$install_from_github" = "1" ] || [ "$install_from_github" = "true" ]; then 266 - tarball_url="https://github.com/jdx/mise/releases/download/v${version}/mise-v${version}-${os}-${arch}.${ext}" 267 - elif [ -n "${MISE_TARBALL_URL-}" ]; then 268 - tarball_url="$MISE_TARBALL_URL" 269 - else 270 - tarball_url="https://mise.jdx.dev/v${version}/mise-v${version}-${os}-${arch}.${ext}" 271 - fi 272 - 273 - download_dir="$(mktemp -d)" 274 - cache_file=$(download_file "$tarball_url" "$download_dir") 275 - debug "mise-setup: tarball=$cache_file" 276 - 277 - debug "validating checksum" 278 - cd "$(dirname "$cache_file")" && get_checksum "$version" "$os" "$arch" "$ext" | "$(shasum_bin)" -c >/dev/null 279 - 280 - # extract tarball 281 - mkdir -p "$install_dir" 282 - rm -rf "$install_path" 283 - extract_dir="$(mktemp -d)" 284 - cd "$extract_dir" 285 - if [ "$ext" = "tar.zst" ] && ! tar_supports_zstd; then 286 - zstd -d -c "$cache_file" | tar -xf - 287 - else 288 - tar -xf "$cache_file" 289 - fi 290 - mv mise/bin/mise "$install_path" 291 - 292 - # cleanup 293 - cd / # Move out of $extract_dir before removing it 294 - rm -rf "$download_dir" 295 - rm -rf "$extract_dir" 296 - 297 - info "mise: installed successfully to $install_path" 298 - } 299 - 300 - after_finish_help() { 301 - case "${SHELL:-}" in 302 - */zsh) 303 - info "mise: run the following to activate mise in your shell:" 304 - info "echo \"eval \\\"\\\$($install_path activate zsh)\\\"\" >> \"${ZDOTDIR-$HOME}/.zshrc\"" 305 - info "" 306 - info "mise: run \`mise doctor\` to verify this is setup correctly" 307 - ;; 308 - */bash) 309 - info "mise: run the following to activate mise in your shell:" 310 - info "echo \"eval \\\"\\\$($install_path activate bash)\\\"\" >> ~/.bashrc" 311 - info "" 312 - info "mise: run \`mise doctor\` to verify this is setup correctly" 313 - ;; 314 - */fish) 315 - info "mise: run the following to activate mise in your shell:" 316 - info "echo \"$install_path activate fish | source\" >> ~/.config/fish/config.fish" 317 - info "" 318 - info "mise: run \`mise doctor\` to verify this is setup correctly" 319 - ;; 320 - *) 321 - info "mise: run \`$install_path --help\` to get started" 322 - ;; 323 - esac 324 - } 325 - 326 - install_mise 327 - if [ "${MISE_INSTALL_HELP-}" != 0 ]; then 328 - after_finish_help 329 - fi 330 - 331 - cd -- "$initial_working_dir" 332 - } 333 - local MISE_INSTALL_HELP=0 334 - test -f "$MISE_INSTALL_PATH" || install 335 - } 336 - __mise_bootstrap 337 - exec "$MISE_INSTALL_PATH" "$@"