Skip to content

Instantly share code, notes, and snippets.

@straight-shoota
Created November 13, 2018 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save straight-shoota/544dd46cb70de1cf9dd1d26fa9d494a4 to your computer and use it in GitHub Desktop.
Save straight-shoota/544dd46cb70de1cf9dd1d26fa9d494a4 to your computer and use it in GitHub Desktop.
Crystal Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
clone_crystal_from_vagrant = lambda do |config|
config.vm.provision :shell, privileged: false, inline: %(
# Checkout crystal repository
git clone /vagrant crystal
)
end
install_apt_repository = lambda do |config|
config.vm.provision :shell, inline: <<-SHELL
curl -sL "https://keybase.io/crystal/pgp_keys.asc" | apt-key add -
echo "deb https://dist.crystal-lang.org/apt crystal main" > /etc/apt/sources.list.d/crystal.list
apt-get update
SHELL
end
Vagrant.configure("2") do |config|
[["precise", '3.5'], ['trusty', '3.5'], ['xenial', '3.8'], ['bionic', '6.0']].product([32, 64]).each do |(dist, llvm_version), bits|
box_name = "#{dist}#{bits}"
# the currently supported 64-bit LTS versions are handled differently
next if box_name == "xenial64" || box_name == "bionic64"
config.vm.define(box_name) do |config|
config.vm.box = "ubuntu/#{box_name}"
install_apt_repository.call(config)
if llvm_version == '3.5'
config.vm.provision :shell, inline: <<-SHELL
curl -s https://crystal-lang.s3.amazonaws.com/llvm/llvm-3.5.0-1-linux-`uname -m`.tar.gz | tar xz -C /opt
echo 'export LIBRARY_PATH="/opt/crystal/embedded/lib"' > /etc/profile.d/crystal.sh
echo 'export PATH="$PATH:/opt/llvm-3.5.0-1/bin"' >> /etc/profile.d/crystal.sh
SHELL
else
config.vm.provision :shell, inline: <<-SHELL
apt-get install llvm-#{llvm_version}-dev
SHELL
end
config.vm.provision :shell, inline: <<-SHELL
# install Crystal build requrirements
apt-get install -y make git libedit-dev g++
# install libraries used in stdlib
apt-get install -y libssl-dev libyaml-dev llibxml2-dev libgmp3-dev zlib1g-dev libreadline-dev
# install Crystal
apt-get install -y crystal
SHELL
clone_crystal_from_vagrant.call(config)
config.vm.provision :shell, privileged: false, inline: <<-SHELL
cd crystal
# Build libcrystal.a and ext.o
make deps
SHELL
end
end
[['xenial', '1604', '3.8'], ['bionic', '1804', '6.0']].each do |dist, version, bits|
box_name = "#{dist}64"
config.vm.define(box_name) do |config|
config.vm.box = "generic/ubuntu#{version}"
install_apt_repository.call(config)
config.vm.provision :shell, inline: <<-SHELL
# install Crystal build requrirements
apt-get install -y make git libedit-dev g++ llvm-#{llvm_version}-dev
# install libraries used in stdlib
apt-get install -y libssl-dev libyaml-dev llibxml2-dev libgmp3-dev zlib1g-dev libreadline-dev
# install Crystal
apt-get install -y crystal
SHELL
clone_crystal_from_vagrant.call(config)
config.vm.provision :shell, privileged: false, inline: <<-SHELL
cd crystal
# Build libcrystal.a and ext.o
make deps
SHELL
end
end
[[:jessie, '3.5'], [:stretch, '3.9']].product([32, 64]).each do |(dist, llvm_version), bits|
box_name = "#{dist}#{bits}"
config.vm.define(box_name) do |config|
config.vm.box = "generic/#{box_name}"
config.vm.provision :shell, inline: <<-SHELL
apt-get install -y apt-transport-https curl dirmngr
SHELL
install_apt_repository.call(config)
config.vm.provision :shell, inline: <<-SHELL
# install Crystal build requrirements
apt-get install -y make git libedit-dev g++ llvm-#{llvm_version} llvm-#{llvm_version}-dev
# install libraries used in stdlib
apt-get install -y libssl-dev libyaml-dev llibxml2-dev libgmp3-dev zlib1g-dev libreadline-dev
# install Crystal
apt-get install -y crystal
SHELL
clone_crystal_from_vagrant.call(config)
config.vm.provision :shell, privileged: false, inline: <<-SHELL
cd crystal
# Build libcrystal.a and ext.o
make deps
SHELL
end
end
config.vm.define "freebsd11" do |config|
config.vm.guest = :freebsd
config.vm.box = "generic/freebsd11"
config.vm.provision :shell, inline: <<-SHELL
pkg update
# install Crystal build requrirements
pkg install -y gmake git
# install libraries used in stdlib
pkg install -y openssl-devel libyaml libxml2 gmp
# install Crystal
pkg install -y crystal shards
SHELL
config.vm.provision :shell, privileged: false, inline: <<-SHELL
# Checkout crystal repository
git clone https://github.com/crystal-lang/crystal.git
cd crystal
echo "LLVM_CONFIG=llvm-config50" > Makefile.local
# Build libcrystal.a and ext.o
gmake deps
SHELL
end
config.vm.define "openbsd" do |config|
config.vm.guest = :openbsd
config.vm.box = "generic/openbsd6"
config.vm.provision :shell, inline: <<-SHELL
# install Crystal build requrirements
pkg_add git gmake pkgconf pcre libunwind libevent
# install libraries used in stdlib
pkg_add libyaml gmp
SHELL
config.vm.provision :shell, privileged: false, inline: <<-SHELL
# Checkout crystal repository
git clone https://github.com/crystal-lang/crystal.git
cd crystal
# Build libcrystal.a and ext.o
gmake deps
SHELL
end
config.vm.define "alpine" do |config|
config.vm.guest = :linux
config.vm.box = "generic/alpine38"
config.vm.provision :shell, inline: <<-SHELL
apk update
# install Crystal requrirements
apk add make llvm5-dev llvm5-static g++
# install libraries used in stdlib
apk add libressl-dev yaml-dev libxml2-dev readline-dev zlib-dev tzdata
# install Crystal
apk add crystal@community shards@community
SHELL
config.vm.provision :shell, privileged: false, inline: <<-SHELL
# Checkout crystal repository
git clone https://github.com/crystal-lang/crystal.git
cd crystal
# Build libcrystal.a and ext.o
make deps
SHELL
end
config.vm.provider "virtualbox" do |vb|
vb.memory = 4096
vb.cpus = 2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment