4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"). You may
6 # only use this file in accordance with the terms of the CDDL.
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright 2016 Adam Stevko. All rights reserved.
17 Vagrant.configure("2") do |config|
18 # Every Vagrant development environment requires a box. You can search for
19 # boxes at https://atlas.hashicorp.com/search.
20 config.vm.box = "openindiana/hipster"
22 # Disable automatic box update checking. If you disable this, then
23 # boxes will only be checked for updates when the user runs
24 # `vagrant box outdated`. This is not recommended.
25 config.vm.box_check_update = true
27 # Unless OpenIndiana is better supported in vagrant, we have to use this
28 # workaround. The problem is with vagrant creating folder as root:root,
29 # but rsync connects as vagrant and fails to write.
30 config.vm.synced_folder ".", "/vagrant", type: "rsync",
31 rsync__args: ["--verbose", "--archive", "-z", "--copy-links"],
32 rsync__rsync_path: "pfexec rsync", owner: "vagrant", group: "vagrant"
34 # Autoconfigure resources for development VM. The snippet is taken from
35 # https://stefanwrobel.com/how-to-make-vagrant-performance-not-suck.
36 # We allocate 1/4 of available system memory and CPU core count of the host
37 # to the VM, so performance does not suck.
38 config.vm.provider "virtualbox" do |v|
39 host = RbConfig::CONFIG['host_os']
41 # Give VM 1/4 system memory and CPU core count
43 # sysctl returns Bytes and we need to convert to MB
44 mem = `sysctl -n hw.memsize`.to_i / 1024
45 cpus = `sysctl -n hw.ncpu`.to_i / 4
47 # meminfo shows KB and we need to convert to MB
48 mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024
49 cpus = `grep -c Processor /proc/cpuinfo`.to_i / 4
50 elsif host =~ /mswin|mingw|cygwin/
51 # Windows code via https://github.com/rdsubhas/vagrant-faster
52 mem = `wmic computersystem Get TotalPhysicalMemory`.split[1].to_i / 1024
58 v.customize ["modifyvm", :id, "--memory", mem]
59 v.customize ["modifyvm", :id, "--cpus", cpus]
62 # Once vagrant is able to chown files on OpenIndiana, chown line should be
63 # removed from this part.
64 config.vm.provision "shell", inline: <<-SHELL
65 pfexec chown -R vagrant:vagrant /vagrant
66 pfexec pkg install build-essential
68 cd /vagrant && gmake setup
69 echo "VM ready, happy contributing!"