Skip to content

Instantly share code, notes, and snippets.

@dbuenzli
Created Dec 21, 2017
Embed
What would you like to do?
Install OCaml 4.06 in a Win10 VM with vagrant
# Download vagrant box for Windows 10 from:
#
# https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
#
# Unzip and add with:
#
# vagrant box add --name win10 MSEdge\ -\ Win10.box
#
# During the first `vagrant up` need to connect to vm UI to do this:
#
# https://gist.github.com/andreptb/57e388df5e881937e62a#gistcomment-1962961
#
# Otherwise the up timesout (it should be possible to make a new vagrant box
# just after that has been done)
Vagrant.configure("2") do |config|
config.vm.box = "win10"
config.vm.guest = :windows
# Setup WinRM
config.vm.communicator = "winrm"
config.winrm.username = "IEUser"
config.winrm.password = "Passw0rd!"
# Setup SSH
config.ssh.username = "IEUser"
config.ssh.password = "Passw0rd!"
config.ssh.insert_key = true
config.vm.provider "virtualbox" do |vb|
vb.name = "Win10 - OCaml 4.06"
# Display the VirtualBox GUI when booting the machine
vb.gui = true
end
# Install chocolatey
$chocolatey = <<-'SCRIPT'
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
SCRIPT
config.vm.provision :shell, inline: $chocolatey
# Install a few packages and sed and make in cygwin
$chocopkgs = <<-'SCRIPT'
chocolatey feature enable -n=allowGlobalConfirmation
choco install git
choco install visualstudio2017buildtools
choco install visualstudio2017-workload-vctools
choco install cygwin
choco install cyg-get
chocolatey feature disable -n=allowGlobalConfirmation
cyg-get sed make
SCRIPT
config.vm.provision :shell, inline: $chocopkgs
# Install OCaml from source in C:\ocamlms64\bin
$ocaml = <<-'SCRIPT'
# The following to avoid problems with sed in OCaml's build system.
git config --global core.autocrlf false
git config --global core.eol lf
git clone https://github.com/ocaml/ocaml.git -b 4.06.0 ocaml
cd ocaml
git submodule update --init
copy config\m-nt.h byterun\caml\m.h
copy config\s-nt.h byterun\caml\s.h
copy config\Makefile.msvc64 config\Makefile
# Setting the cygwin path first and then VS is important to avoid the clash
# on the link tool
cmd.exe /c --% "SET PATH=C:\tools\cygwin\bin;%PATH% & "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"" -arch=amd64 & make -f Makefile.nt flexdll world bootstrap opt opt.opt install
cd ..
Remove-Item ocaml -Force -Recurse
SCRIPT
config.vm.provision :shell, inline: $ocaml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment