Giter Site home page Giter Site logo

asdf-nim's Introduction

build lint Join the chat at https://gitter.im/asdf-nim/community

asdf-nim

asdf-nim allows you to quickly install any version of Nim.

asdf-nim is intended for end-users and continuous integration. Whether macOS or Linux, x86 or ARM - all you'll need to install Nim is bash.

Installation

Install asdf, then:

asdf plugin add nim # install the asdf-nim plugin
asdf nim install-deps  # install system-specific dependencies for downloading & building Nim

To install Nim:

When available for the version and platform, the plugin will install pre-compiled binaries of Nim. If no binaries are available the plugin will build Nim from source.

# latest stable version of Nim
asdf install nim latest
# or latest stable minor/patch release of Nim 1.x.x
asdf install nim latest:1
# or latest stable patch release of Nim 1.6.x
asdf install nim latest:1.6
# or specific patch release
asdf install nim 1.6.8

To install a nightly build of Nim:

# nightly unstable build of devel branch
asdf install nim ref:devel
# or nightly unstable build of version-1-6 branch, i.e. the latest 1.6.x release + any recent backports from devel
asdf install nim ref:version-1-6
# or nightly unstable build of version-1-4 branch, i.e. the latest 1.4.x release + any recent backports from devel
asdf install nim ref:version-1-4
# or nightly unstable build of version-1-2 branch, i.e. the 1.2.x release + any recent backports from devel
asdf install nim ref:version-1-2
# or nightly unstable build of version-1-0 branch, i.e. the 1.0.x release + any recent backports from devel
asdf install nim ref:version-1-0

To build a specific git commit or branch of Nim:

# build using latest commit from the devel branch
asdf install nim ref:HEAD
# build using the specific commit 7d15fdd
asdf install nim ref:7d15fdd
# build using the tagged release v1.6.8
asdf install nim ref:v1.6.8

To set the default version of Nim for your user:

asdf global nim latest:1.6

This creates a .tool-versions file in your home directory specifying the Nim version.

To set the version of Nim for a project directory:

cd my-project
asdf local nim latest:1.6

This creates a .tool-versions file in the current directory specifying the Nim version. For additional plugin usage see the asdf documentation.

Nimble packages

Nimble packages are installed in ~/.asdf/installs/nim/<nim-version>/nimble/pkgs, unless a nimbledeps directory exists in the directory where nimble install is run from.

See the nimble documentation for more information about nimbledeps.

Continuous Integration

A simple example using GitHub Actions:

name: Build
on:
  push:
    paths-ignore:
      - README.md

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  build:
    name: Test
    runs-on: ${{ matrix.os }}
    matrix:
      include:
        # Test against stable Nim builds on linux
        - os: ubuntu-latest
          nim-version: latest:1.6
        - os: ubuntu-latest
          nim-version: latest:1.4

        # Test against unstable nightly Nim builds on macos (faster than building from source)
        - os: macos-latest
          nim-version: ref:version-1-6
        - os: macos-latest
          nim-version: ref:version-1-4
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install Nim
        uses: asdf-vm/actions/install@v1
        with:
          tool_versions: |
            nim ${{ matrix.nim-version }}
      - name: Run tests
        run: |
          asdf local nim ${{ matrix.nim-version }}
          nimble develop -y
          nimble test
          nimble examples

Continuous Integration on Non-x86 Architectures

Using uraimo/run-on-arch-action:

name: Build
on:
  push:
    paths-ignore:
      - README.md

jobs:
  test_non_x86:
    name: Test nim-${{ matrix.nim-version }} / debian-buster / ${{ matrix.arch }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - nim-version: ref:version-1-6
            arch: armv7
          - nim-version: ref:version-1-2
            arch: aarch64

    runs-on: ubuntu-latest
    steps:
      - name: Checkout Nim project
        uses: actions/checkout@v2

      - uses: uraimo/run-on-arch-action@v2
        name: Install Nim & run tests
        with:
          arch: ${{ matrix.arch }}
          distro: buster

          dockerRunArgs: |
            --volume "${HOME}/.cache:/root/.cache"

          setup: mkdir -p "${HOME}/.cache"

          shell: /usr/bin/env bash

          install: |
            set -uexo pipefail
            # Install asdf and dependencies
            apt-get update -q -y
            apt-get -qq install -y build-essential curl git
            git clone https://github.com/asdf-vm/asdf.git "${HOME}/.asdf" --branch v0.10.2

          env: |
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

          run: |
            set -uexo pipefail
            . "${HOME}/.asdf/asdf.sh"

            # Install asdf-nim and dependencies
            git clone https://github.com/asdf-community/asdf-nim.git ~/asdf-nim --branch main --depth 1
            asdf plugin add nim ~/asdf-nim
            asdf nim install-deps -y

            # Install Nim
            asdf install nim ${{ matrix.nim-version }}
            asdf local nim ${{ matrix.nim-version }}

            # Run tests
            nimble develop -y
            nimble test
            nimble examples

Stable binaries

nim-lang.org supplies pre-compiled stable binaries of Nim for:

Linux:

  • x86_64 (gnu libc)
  • x86 (gnu libc)

Unstable nightly binaries

nim-lang/nightlies supplies pre-compiled unstable binaries of Nim for:

Linux:

  • x86_64 (gnu libc)
  • x86 (gnu libc)
  • aaarch64 (gnu libc)
  • armv7l (gnu libc)

macOS:

  • x86_64

Updating asdf and asdf-nim

asdf update
asdf plugin update nim main

Contributing

Pull requests are welcome!

Fork this repo, then run:

rm -rf ~/.asdf/plugins/nim
git clone [email protected]:<your-username>/asdf-nim.git ~/.asdf/plugins/nim

Testing

This project uses bats for unit testing. Please follow existing patterns and add unit tests for your changeset. Dev dependencies for unit tests are installed via:

cd ~/.asdf/plugins/nim
npm install --include=dev

Run tests with:

npm run test

Linting

This project uses lintball to auto-format code. Please ensure your changeset passes linting. Enable the githooks with:

git config --local core.hooksPath .githooks

asdf-nim's People

Contributors

elijahr avatar github-actions[bot] avatar gitter-badger avatar ire4ever1190 avatar jkl1337 avatar joxcat avatar renovate[bot] avatar smorimoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

asdf-nim's Issues

`nimbledeps` folder is ignored

Describe the bug

The nimbledeps folder is ignored when invoking nimble. This is a feature of nimble that is used for project local dependencies.

Steps to reproduce

  1. Create .nimble file with a dependency, for instance:
version = "0.1.0"
author = "bug reporter"
description = "showcases a bug in asdf-nim"
license = "MIT"

requires "asynctest"
  1. Create an empty nimbledeps folder next to the .nimble file.
  2. Invoke nimble install -d -y
  3. Look inside the nimbledeps folder, and see that it's empty.

Expected behavior

At step 4 the nimbledeps/pkgs folder should contain the downloaded dependencies.

Screenshots

user@work:~/tmp$ cat reproduce.nimble 
version = "0.1.0"
author = "bug reporter"
description = "showcases a bug in asdf-nim"
license = "MIT"

requires "asynctest"
user@work:~/tmp$ mkdir nimbledeps
user@work:~/tmp$ nimble install -d -y
   Warning: Using the environment variable: NIMBLE_DIR='/home/user/.asdf/installs/nim/1.4.8/nimble'
  Verifying dependencies for [email protected]
 Installing asynctest@any version
Downloading https://github.com/markspanbroek/asynctest using git
  Verifying dependencies for [email protected]
 Installing [email protected]
   Success: asynctest installed successfully.
  asdf-nim: regenerated shims

user@work:~/tmp$ ls nimbledeps/
user@work:~/tmp$ 

Additional context

It seems that asdf-vm sets the NIMBLE_DIR environment variable, which overrides the default behaviour of nimble when a nimbledeps folder is present.

ASDF_DATA_DIR not set sensibly?

The plugin does not do what I expect if asdf is installed in a non-world writeable location such as /opt/asdf. In that case asdf will default to using ~/.asdf for it's data directory (see asdf_data_dir function in utils.bash), however this plugin builds it off of the script install location, so /opt/asdf, and it will fail when it tries to make a tmp dir there. I think the plugin should use the same default as asdf for the data directory.

Fails to install Nim 1.4.6

Describe the bug

❯ asdf install nim 1.4.6

# Installing
# ↳ Running install.sh … 
# 😱 Exited with status 1:

/home/rikusen/.asdf/plugins/nim/bin/../lib/utils.bash: line 549: ASDF_DOWNLOAD_PATH: unbound variable
/home/rikusen/.asdf/plugins/nim/bin/../lib/utils.bash: line 750: ASDF_DOWNLOAD_PATH: unbound variable
/home/rikusen/.asdf/plugins/nim/bin/install: line 38: ASDF_DOWNLOAD_PATH: unbound variable

# Cleaning up install directory…

Steps to reproduce
Just trying to this: asdf install nim 1.4.6

Expected behavior
asdf-vm installs nim through the plugin.

Screenshots
Nothing

Additional context
Nothing

`nimble` shows unbound variable error

Describe the bug

nimble shows /path/to/home/.asdf/plugins/nim/shims/nimble: line 24: $1: unbound variable and nimble's help.
nimble -h shows nimble's help.

Steps to reproduce

Just type nimble

Expected behavior

nimble just shows nimble's help

Screenshots

image

Additional context

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

docker-compose
docker-compose.yml
dockerfile
Dockerfile
github-actions
.github/workflows/build.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/cache v3
  • asdf-vm/actions v1
  • actions/checkout v3
  • actions/cache v3
  • asdf-vm/actions v1
  • actions/cache v3
  • actions/checkout v3
  • uraimo/run-on-arch-action v2
.github/workflows/lint.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/setup-python v4
  • mfinelli/setup-shfmt v2
npm
package.json
  • bats ^1.8.2
  • bats-assert 44913ff
  • bats-support ^0.3.0
  • lintball ^1.6.0

  • Check this box to trigger a request for Renovate to run again on this repository

Remove "packages" section from main page

@smorimoto when you get a chance, can you remove the "Packages" section from the main page?

These are docker images used internally by the arm/ppc builds via run-on-arch-action. It's not a problem to have them there, they just clutter the page.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.