├── LICENSE ├── README.md ├── bin └── nim-vm ├── scripts └── install.sh └── vagrant └── Vagrantfile /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (C) 2015 Endre Karlson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Nim Version Manager 2 | =================== 3 | 4 | ## 0tt0matic installation 5 | ```curl https://raw.githubusercontent.com/ekarlso/nimvm/master/scripts/install.sh | sh``` 6 | 7 | ## Manual installation 8 | 9 | ``` 10 | mkdir -p ~/.nimvm/bin 11 | curl -o ~/.nimvm/bin/nim-vm https://raw.githubusercontent.com/ekarlso/nimvm/master/bin/nim-vm 12 | chmod +x ~/.nimvm/bin/nim-vm 13 | ``` 14 | 15 | Then add `~/.nimvm/bin` to your PATH such that it is the source for your `nim` invocations. 16 | 17 | ## Examples of usage 18 | 19 | ``` 20 | nim-vm install v0.10.2 # installs latest release 21 | nim-vm install devel # installs current version in development 22 | nim-vm install v0.9.6 # installs the old verision 23 | nim-vm active # shows which version is used 24 | nim-vm list # lists all installed versions 25 | nim-vm use v0.10.2 # switches to latest release 26 | nim-vm use devel # switches to the development version 27 | nim-vm update # updates the development version from development repo 28 | ``` 29 | 30 | You can also set the env variable `$NIM_REPO_LOCATION` which then acts as version `repo` 31 | 32 | ``` 33 | nim-vm use repo # uses "your own" repo 34 | nim-vm rebuild repo # rebuilds your own repo 35 | nim-vm use devel # switches to the devel repo 36 | nim-vm use repo # swichtes back to your personal repo 37 | ``` 38 | 39 | ### Modifications 40 | 41 | The script does define some common -d flags to the koch build. You may want to change these for your needs 42 | -------------------------------------------------------------------------------- /bin/nim-vm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 4 | 5 | # Nim repo to use 6 | NIM_REPO=http://github.com/Araq/Nim.git 7 | 8 | # Where to store nim-versions 9 | NIM_DIR=${NIM_DIR:-~/.nimvm} 10 | NIM_BIN_DIR=${NIM_BIN_DIR:-} 11 | 12 | NIMVM_ACTIVATE=0 13 | NIMVM_VERSION_LINK=${NIMVM_VERSION_LINK:-1} 14 | 15 | # if version "repo" is used the directory used is $NIM_REPO_LOCATION 16 | 17 | platform='unknown' 18 | unamestr=`uname` 19 | if [[ "$unamestr" == 'Linux' ]]; then 20 | platform='linux' 21 | elif [[ "$unamestr" == 'Darwin' ]]; then 22 | platform='darwin' 23 | fi 24 | 25 | if [ "$platform" == "darwin" ]; then 26 | KOCH_FLAGS="-d:release -d:useGnuReadline -d:nativeStacktrace -d:avoidTimeMachine" 27 | TIMEOUT_CMD="gtimeout" 28 | elif [ "$platform" == "linux" ]; then 29 | KOCH_FLAGS="-d:release -d:useGnuReadline -d:nativeStacktrace" 30 | TIMEOUT_CMD="timeout" 31 | else 32 | KOCH_FLAGS="-d:release" 33 | TIMEOUT_CMD="timeout" 34 | fi 35 | 36 | VERSION="0.3.0" 37 | 38 | get_location() { 39 | link=$(readlink ${BASH_SOURCE[0]}) 40 | 41 | if [ -f "$link" ]; then 42 | path=$(dirname $link)/.. 43 | else 44 | path=$DIR/.. 45 | fi 46 | 47 | echo $path 48 | } 49 | 50 | nimvm_version() { 51 | local version=$VERSION 52 | path=$(get_location) 53 | 54 | [ -d "$path/.git" ] && { 55 | version=$(cd $path; git log --pretty=format:'%h' -n 1) 56 | } 57 | 58 | echo $version 59 | } 60 | 61 | function err { 62 | local exitcode=$? 63 | local xtrace=$(set +o | grep xtrace) 64 | set +o xtrace 65 | local msg="[ERROR] ${BASH_SOURCE[2]}:$1 $2" 66 | echo $msg 1>&2; 67 | if [[ -n ${LOGDIR} ]]; then 68 | echo $msg >> "${LOGDIR}/error.log" 69 | fi 70 | $xtrace 71 | exit $exitcode 72 | } 73 | 74 | 75 | function backtrace { 76 | if [ -z "$DEBUG" ]; then 77 | return 78 | fi 79 | local level=$1 80 | local deep=$((${#BASH_SOURCE[@]} - 1)) 81 | echo "[Call Trace]" 82 | while [ $level -le $deep ]; do 83 | echo "${BASH_SOURCE[$deep]}:${BASH_LINENO[$deep-1]}:${FUNCNAME[$deep-1]}" 84 | deep=$((deep - 1)) 85 | done 86 | } 87 | 88 | # Prints line number and "message" then exits 89 | # die $LINENO "message" 90 | function die { 91 | local exitcode=$? 92 | set +o xtrace 93 | local line=$1; shift 94 | if [ $exitcode == 0 ]; then 95 | exitcode=1 96 | fi 97 | backtrace 2 98 | err $line "$*" 99 | # Give buffers a second to flush 100 | sleep 1 101 | exit $exitcode 102 | } 103 | 104 | 105 | function git_timed { 106 | local count=0 107 | local timeout=0 108 | 109 | if [[ -n "${GIT_TIMEOUT}" ]]; then 110 | timeout=${GIT_TIMEOUT} 111 | fi 112 | 113 | until $TIMEOUT_CMD -s SIGINT ${timeout} git "$@"; do 114 | # 124 is timeout(1)'s special return code when it reached the 115 | # timeout; otherwise assume fatal failure 116 | if [[ $? -ne 124 ]]; then 117 | die $LINENO "git call failed: [git $@]" 118 | fi 119 | 120 | count=$(($count + 1)) 121 | warn "timeout ${count} for git call: [git $@]" 122 | if [ $count -eq 3 ]; then 123 | die $LINENO "Maximum of 3 git retries reached" 124 | fi 125 | sleep 5 126 | done 127 | } 128 | 129 | # git update using reference as a branch. 130 | # git_update_branch ref 131 | function git_update_branch { 132 | local git_branch=$1 133 | 134 | git checkout -f origin/$git_branch 135 | # a local branch might not exist 136 | git branch -D $git_branch || true 137 | git checkout -b $git_branch 138 | } 139 | 140 | # git update using reference as a branch. 141 | # git_update_remote_branch ref 142 | function git_update_remote_branch { 143 | local git_branch=$1 144 | 145 | git checkout -b $git_branch -t origin/$git_branch 146 | } 147 | 148 | # git update using reference as a tag. Be careful editing source at that repo 149 | # as working copy will be in a detached mode 150 | # git_update_tag ref 151 | function git_update_tag { 152 | local git_tag=$1 153 | 154 | git tag -d $git_tag 155 | # fetching given tag only 156 | git_timed fetch origin tag $git_tag 157 | git checkout -f $git_tag 158 | } 159 | 160 | function get_bindir() { 161 | # Default to $NIMDIR/bin 162 | bindir=$NIM_DIR/bin 163 | [ ! -z "$NIM_BIN_DIR" ] && bindir=$NIM_BIN_DIR 164 | echo $bindir 165 | } 166 | function activate() { 167 | local version=$1 168 | local version_dir="$NIM_DIR/versions/$version" 169 | 170 | if [ ! -d "$version_dir" ]; then 171 | die $LINENO "Version not found $version" 172 | fi 173 | } 174 | 175 | function koch_build() { 176 | if [ ! -d "csources" ]; then 177 | case "$1" in 178 | (v0.9.*) 179 | git clone --branch v0.9.4 --depth 1 https://github.com/nim-lang/csources.git 180 | cd "csources" 181 | sh build.sh 182 | cd ".." 183 | ./bin/nimrod c koch 184 | ;; 185 | (*) 186 | git clone --depth 1 https://github.com/nim-lang/csources.git 187 | cd "csources" 188 | sh build.sh 189 | cd ".." 190 | ./bin/nim c koch 191 | ;; 192 | esac 193 | fi 194 | 195 | ./koch boot $KOCH_FLAGS 196 | 197 | case "$1" in 198 | (v0.9.*) 199 | if [ ! -f bin/nim ]; then 200 | # make it available as nim 201 | ln -s nimrod bin/nim 202 | fi 203 | ;; 204 | esac 205 | } 206 | 207 | function get_versiondir() { 208 | local version=$1 209 | if [ "$version" == "repo" ]; then 210 | if [ -z "$NIM_REPO_LOCATION" ]; then 211 | echo "Nim reposiory location (NIM_REPO_LOCATION) not set" 212 | exit 5 213 | fi 214 | echo "$NIM_REPO_LOCATION" 215 | else 216 | echo "$NIM_DIR/versions/$version" 217 | fi 218 | } 219 | 220 | function install_version() { 221 | local version=$1 222 | 223 | if [ -z "$version" ]; then 224 | die $LINENO "Version not specified." 225 | fi 226 | 227 | mkdir -p $NIM_DIR/versions 228 | 229 | local version_dir=$(get_versiondir $version) 230 | 231 | if [ -d $version_dir ]; then 232 | die $LINENO "Version $version already exists.." 233 | fi 234 | 235 | NIM_CACHE=$NIM_DIR/repo_cache 236 | if [ ! -d $NIM_CACHE ]; then 237 | echo "No cacehd repository found, cloning $NIM_REPO to $NIM_CACHE..." 238 | git_timed clone $NIM_REPO $NIM_CACHE 239 | else 240 | echo "Using cached repository $NIM_CACHE" 241 | fi 242 | 243 | cp -R $NIM_CACHE $version_dir 244 | 245 | cd $version_dir 246 | git remote set-url origin $NIM_REPO 247 | git_timed fetch origin 248 | 249 | # handle git_ref accordingly to type (tag, branch) 250 | if [[ -n "`git show-ref refs/tags/$version`" ]]; then 251 | git_update_tag $version 252 | elif [[ -n "`git show-ref refs/heads/$version`" ]]; then 253 | git_update_branch $version 254 | elif [[ -n "`git show-ref refs/remotes/origin/$version`" ]]; then 255 | git_update_remote_branch $version 256 | else 257 | die $LINENO "$version is neither branch nor tag" 258 | fi 259 | 260 | koch_build $version 261 | 262 | bindir=$(get_bindir) 263 | if [ "$NIMVM_VERSION_LINK" = "1" ]; then 264 | ln -nfs $version_dir/bin/nim $bindir/nim.$version 265 | fi 266 | } 267 | 268 | function update_version() { 269 | local version=$1 270 | 271 | if [ -z "$version" ]; then 272 | die $LINENO "Version not specified." 273 | fi 274 | 275 | local version_dir=$(get_versiondir $version) 276 | 277 | if [ "$version" == "repo" ]; then 278 | die $LINENO "Local repo should be handled manually." 279 | fi 280 | 281 | if [ ! -d $version_dir ]; then 282 | die $LINENO "Version $version does not exists.." 283 | fi 284 | 285 | cd $version_dir 286 | git_timed fetch origin 287 | 288 | # handle git_ref accordingly to type (tag, branch) 289 | if [[ -n "`git show-ref refs/tags/$version`" ]]; then 290 | git_update_tag $version 291 | elif [[ -n "`git show-ref refs/heads/$version`" ]]; then 292 | git_update_branch $version 293 | elif [[ -n "`git show-ref refs/remotes/origin/$version`" ]]; then 294 | git_update_remote_branch $version 295 | else 296 | die $LINENO "$version is neither branch nor tag" 297 | fi 298 | 299 | koch_build $version 300 | 301 | bindir=$(get_bindir) 302 | if [ "$NIMVM_VERSION_LINK" = "1" ]; then 303 | ln -nfs $version_dir/bin/nim $bindir/nim.$version 304 | fi 305 | } 306 | 307 | function rebuild_version() { 308 | local version=$1 309 | 310 | if [ -z "$version" ]; then 311 | die $LINENO "Version not specified." 312 | fi 313 | 314 | local version_dir=$(get_versiondir $version) 315 | 316 | if [ ! -d $version_dir ]; then 317 | die $LINENO "Version $version does not exists.." 318 | fi 319 | 320 | cd $version_dir 321 | 322 | koch_build $version 323 | 324 | bindir=$(get_bindir) 325 | if [ "$NIMVM_VERSION_LINK" = "1" ]; then 326 | ln -nfs $version_dir/bin/nim $bindir/nim.$version 327 | fi 328 | } 329 | 330 | function remove_version() { 331 | local version=$1 332 | if [ $version == "repo" ]; then 333 | die $LINENO "Cannot remove 'repo' version" 334 | fi 335 | local version_dir=$(get_versiondir $version) 336 | 337 | if [ ! -d "$version_dir" ]; then 338 | die $LINENO "Version $version doesn't exist." 339 | fi 340 | 341 | rm -rf "$version_dir" 342 | } 343 | 344 | function get_active_version() { 345 | local bindir=$(get_bindir) 346 | local active_link=$bindir/nim 347 | path=$(readlink $active_link) 348 | if [[ "$NIM_REPO_LOCATION/bin/nim" == "$path" ]]; then 349 | echo "repo" 350 | elif [ -f "$path" ]; then 351 | echo $(basename $(cd $(dirname $path)/..; pwd)) 352 | fi 353 | } 354 | 355 | function active_version() { 356 | local active=$(get_active_version) 357 | [ -z "$active" ] && die $LINENO "No active version" 358 | echo $active 359 | } 360 | 361 | function get_versions() { 362 | local version_dir="$NIM_DIR/versions" 363 | if [ ! -d "$version_dir" ]; then 364 | return 365 | fi 366 | 367 | versions="" 368 | for i in $version_dir/*; do 369 | if [ ! -x $i/bin/nim ]; then 370 | continue 371 | fi 372 | name=$(basename $i) 373 | versions+=" $name" 374 | done 375 | echo $versions 376 | } 377 | 378 | function list_versions() { 379 | local active=$(get_active_version) 380 | local versions=$(get_versions) 381 | 382 | if [ -z "$versions" ]; then 383 | echo "No versions installed currently" 384 | exit 0 385 | fi 386 | 387 | for i in $versions; do 388 | echo -ne "-> $i" 389 | if [ "$active" == $i ]; then 390 | echo -ne " (active)" 391 | fi 392 | echo 393 | done 394 | } 395 | 396 | function use_version() { 397 | local version=$1 398 | local version_dir=$(get_versiondir $version) 399 | local bindir=$(get_bindir) 400 | 401 | if [ "$version" == "repo" ]; then 402 | if [ -z "$NIM_REPO_LOCATION" ]; then 403 | die $LINENO "Nim reposiory location (NIM_REPO_LOCATION) not set" 404 | 405 | fi 406 | local version_dir="$NIM_REPO_LOCATION" 407 | fi 408 | 409 | if [ ! -d "$version_dir" ]; then 410 | echo $version_dir 411 | die $LINENO "Version $version doesn't exist. Can't activate." 412 | fi 413 | 414 | [ -w "$bindir/nim" ] && rm $bindir/nim 415 | ln -s $version_dir/bin/nim $bindir/nim 416 | 417 | echo "Now using $version at $bindir/nim" 418 | } 419 | 420 | while getopts ":d:b:a" opt; do 421 | case "${opt}" in 422 | a) 423 | NIMVM_ACTIVATE=1 424 | ;; 425 | b) 426 | NIM_BIN_DIR=$OPTARG 427 | ;; 428 | d) 429 | NIM_DIR=$OPTARG 430 | ;; 431 | esac 432 | done 433 | 434 | shift "$((OPTIND-1))" # Shift off the options and optional --. 435 | 436 | case $1 in 437 | install) 438 | install_version $2 439 | if [ "$NIMVM_ACTIVATE" = "1" ]; then 440 | use_version $2 441 | fi 442 | ;; 443 | uninstall) 444 | remove_version $2 445 | ;; 446 | update) 447 | if [ -z "$2" ]; then 448 | update_version $(get_active_version) 449 | else 450 | update_version $2 451 | if [ "$NIMVM_ACTIVATE" = "1" ]; then 452 | use_version $2 453 | fi 454 | fi 455 | ;; 456 | rebuild) 457 | if [ -z "$2" ]; then 458 | rebuild_version $(get_active_version) 459 | else 460 | rebuild_version $2 461 | if [ "$NIMVM_ACTIVATE" = "1" ]; then 462 | use_version $2 463 | fi 464 | fi 465 | ;; 466 | list) 467 | list_versions 468 | ;; 469 | active) 470 | active_version 471 | ;; 472 | use) 473 | use_version $2 474 | ;; 475 | *) 476 | echo "Usage - Nim version manager $(nimvm_version):" 477 | echo " $0 install install version and use it" 478 | echo " $0 uninstall uninstall version" 479 | echo " $0 update () update current (or version and use it)" 480 | echo " $0 rebuild () rebuild current (or version and use it)" 481 | echo " $0 list list versions" 482 | echo " $0 active show active version" 483 | echo " $0 activate|use use a version" 484 | ;; 485 | esac 486 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 4 | 5 | nimvm_has() { 6 | type "$1" > /dev/null 2>&1 7 | } 8 | 9 | METHOD=${METHOD:-} 10 | 11 | NIMVM_DIR=${NIMVM_DIR:-$HOME/.nimvm} 12 | 13 | nimvm_latest_version() { 14 | echo "v0.3.0" 15 | } 16 | 17 | # 18 | # Outputs the location to NIMVM depending on: 19 | # * The availability of $NIMVM_SOURCE 20 | # * The method used ("script" or "git" in the script, defaults to "git") 21 | # 22 | nimvm_source() { 23 | local NIMVM_METHOD="$1" 24 | local NIMVM_SOURCE_URL="$NIMVM_SOURCE" 25 | 26 | if [ "_$NIMVM_METHOD" = "_script" ]; then 27 | NIMVM_SOURCE_URL="https://raw.githubusercontent.com/ekarlso/nim-vm/$(nimvm_latest_version)/nim-vm" 28 | elif [ -z "$NIMVM_SOURCE_URL" ]; then 29 | if [ "_$NIMVM_METHOD" = "_git" ] || [ -z "$NIMVM_METHOD" ]; then 30 | NIMVM_SOURCE_URL="https://github.com/ekarlso/nim-vm.git" 31 | else 32 | echo >&2 "Unexpected value \"$NIMVM_METHOD\" for \$NIMVM_METHOD" 33 | return 1 34 | fi 35 | fi 36 | echo "$NIMVM_SOURCE_URL" 37 | } 38 | 39 | nimvm_download() { 40 | if nimvm_has "curl"; then 41 | curl $* 42 | elif nimvm_has "wget"; then 43 | # Emulate curl with wget 44 | ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \ 45 | -e 's/-L //' \ 46 | -e 's/-I /--server-response /' \ 47 | -e 's/-s /-q /' \ 48 | -e 's/-o /-O /' \ 49 | -e 's/-C - /-c /') 50 | wget $ARGS 51 | fi 52 | } 53 | 54 | install_nimvm_as_symlink() { 55 | local bindir=$NIMVM_DIR/bin 56 | 57 | # This assumes we're installing from the repository in symlink mode. useful for dev / test or if you want to be on the latest version of the repository 58 | if [ -x "$NIMVM_DIR/nim-vm" ]; then 59 | die $LINENO "nim-vm is already installed at $NIMVM_DIR." 60 | fi 61 | 62 | mkdir -p $bindir 63 | ln -nfs $DIR/../bin/nim-vm $bindir 64 | } 65 | 66 | install_nimvm_from_git() { 67 | if [ -d "$NIMVM_DIR/.git" ]; then 68 | echo "=> nim-vm is already installed in $NIMVM_DIR, trying to update using git" 69 | printf "\r=> " 70 | cd "$NIMVM_DIR" && (command git fetch 2> /dev/null || { 71 | echo >&2 "Failed to update nimvm, run 'git fetch' in $NIMVM_DIR yourself." && exit 1 72 | }) 73 | else 74 | # Cloning to $NIMVM_DIR 75 | echo "=> Downloading nimvm from git to '$NIMVM_DIR'" 76 | printf "\r=> " 77 | mkdir -p "$NIMVM_DIR" 78 | command git clone "$(nimvm_source git)" "$NIMVM_DIR" 79 | fi 80 | cd "$NIMVM_DIR" && command git checkout --quiet $(nimvm_latest_version) && command git branch --quiet -D master >/dev/null 2>&1 81 | return 82 | } 83 | 84 | install_nimvm_as_script() { 85 | local nimvm_source=$(nimvm_source script) 86 | 87 | local bindir=$NIMVM_DIR/bin 88 | # Downloading to $NVM_DIR 89 | mkdir -p "$bindir" 90 | 91 | if [ -f "$bindir/nim-vm" ]; then 92 | echo "=> nim-vm is already installed in $bindir, trying to update the script" 93 | else 94 | echo "=> Downloading nim-vm as script to '$bindir'" 95 | fi 96 | nimvm_download -s "$nimvm_source" -o "$bindir/nim-vm" || { 97 | echo >&2 "Failed to download '$nimvm_source'" 98 | return 1 99 | } 100 | 101 | chmod +x $bindir/nim-vm 102 | } 103 | 104 | # 105 | # Detect profile file if not specified as environment variable 106 | # (eg: PROFILE=~/.myprofile) 107 | # The echo'ed path is guaranteed to be an existing file 108 | # Otherwise, an empty string is returned 109 | # 110 | nimvm_detect_profile() { 111 | if [ -f "$PROFILE" ]; then 112 | echo "$PROFILE" 113 | elif [ -f "$HOME/.bashrc" ]; then 114 | echo "$HOME/.bashrc" 115 | elif [ -f "$HOME/.bash_profile" ]; then 116 | echo "$HOME/.bash_profile" 117 | elif [ -f "$HOME/.zshrc" ]; then 118 | echo "$HOME/.zshrc" 119 | elif [ -f "$HOME/.profile" ]; then 120 | echo "$HOME/.profile" 121 | fi 122 | } 123 | 124 | nimvm_do_install() { 125 | if [ -z "$METHOD" ]; then 126 | # Autodetect install method 127 | if nimvm_has "git"; then 128 | install_nimvm_from_git 129 | elif nimvm_has "nimvm_download"; then 130 | install_nimvm_as_script 131 | else 132 | echo >&2 "You need git, curl, or wget to install nvm" 133 | exit 1 134 | fi 135 | elif [ "~$METHOD" = "~git" ]; then 136 | if ! nimvm_has "git"; then 137 | echo >&2 "You need git to install nim-vm" 138 | exit 1 139 | fi 140 | install_nimvm_from_git 141 | elif [ "~$METHOD" = "~script" ]; then 142 | if ! nimvm_has "nimvm_download"; then 143 | echo >&2 "You need curl or wget to install nim-vm" 144 | exit 1 145 | fi 146 | install_nimvm_as_script 147 | elif [ "~$METHOD" = "~symlink" ]; then 148 | install_nimvm_as_symlink 149 | else 150 | echo "Unsupported method $METHOD." 151 | exit 1 152 | fi 153 | 154 | local NIMVM_PROFILE 155 | NIMVM_PROFILE=$(nimvm_detect_profile) 156 | 157 | SOURCE_STR="export PATH=\$PATH:\"$NIMVM_DIR/bin\"" 158 | 159 | if [ -z "$NIMVM_PROFILE" ] ; then 160 | echo "=> Profile not found. Tried $NIMVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile." 161 | echo "=> Create one of them and run this script again" 162 | echo "=> Create it (touch $NIMVM_PROFILE) and run this script again" 163 | echo " OR" 164 | echo "=> Append the following lines to the correct file yourself:" 165 | printf "\n$SOURCE_STR" 166 | echo 167 | else 168 | if ! grep -qc "$SOURCE_STR" "$NIMVM_PROFILE"; then 169 | echo "=> Appending source string to $NIMVM_PROFILE" 170 | printf "\n$SOURCE_STR\n" >> "$NIMVM_PROFILE" 171 | else 172 | echo "=> Source string already in $NIMVM_PROFILE" 173 | fi 174 | fi 175 | 176 | nimvm_reset 177 | } 178 | 179 | # 180 | # Unsets the various functions defined 181 | # during the execution of the install script 182 | # 183 | nimvm_reset() { 184 | unset -f nimvm_reset nimvm_has nimvm_latest_version \ 185 | nimvm_source nimvm_download install_nimvm_as_script install_nimvm_from_git \ 186 | nimvm_detect_profile nimvm_check_global_modules nimvm_do_install 187 | } 188 | 189 | nimvm_do_install 190 | -------------------------------------------------------------------------------- /vagrant/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | $script = <