1 { stdenv, lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive
2 , libguestfs, qemu, writeText, withLibvirt ? stdenv.isLinux
6 # NOTE: bumping the version and updating the hash is insufficient;
7 # you must use bundix to generate a new gemset.nix in the Vagrant source.
9 url = "https://github.com/hashicorp/vagrant/archive/v${version}.tar.gz";
10 sha256 = "sha256-Tw5rHUZuJt6taCxNSEPo9koBLrpL6RUGrmxtNNPZyPk=";
12 deps = bundlerEnv rec {
13 name = "${pname}-${version}";
18 gemfile = writeText "Gemfile" "";
19 lockfile = writeText "Gemfile.lock" "";
20 gemset = lib.recursiveUpdate (import ./gemset.nix) ({
28 } // lib.optionalAttrs withLibvirt (import ./gemset_libvirt.nix));
30 # This replaces the gem symlinks with directories, resolving this
31 # error when running vagrant (I have no idea why):
32 # /nix/store/p4hrycs0zaa9x0gsqylbk577ppnryixr-vagrant-2.2.6/lib/ruby/gems/2.6.0/gems/i18n-1.1.1/lib/i18n/config.rb:6:in `<module:I18n>': uninitialized constant I18n::Config (NameError)
34 for gem in "$out"/lib/ruby/gems/*/gems/*; do
35 cp -a "$gem/" "$gem.new"
37 # needed on macOS, otherwise the mv yields permission denied
45 name = "${gemName}-${version}";
49 doInstallCheck = true;
51 src = fetchurl { inherit url sha256; };
54 ./unofficial-installation-nowarn.patch
55 ./use-system-bundler-version.patch
56 ./0004-Support-system-installed-plugins.patch
57 ./0001-Revert-Merge-pull-request-12225-from-chrisroberts-re.patch
61 substituteInPlace lib/vagrant/plugin/manager.rb --subst-var-by \
62 system_plugin_dir "$out/vagrant-plugins"
66 # - libarchive: Make `bsdtar` available for extracting downloaded boxes
68 # - libguestfs: Make 'virt-sysprep' available for 'vagrant package'
69 # - qemu: Make 'qemu-img' available for 'vagrant package'
72 pathAdditions = lib.makeSearchPath "bin"
73 (map (x: lib.getBin x) ([
75 ] ++ lib.optionals withLibvirt [
80 wrapProgram "$out/bin/vagrant" \
81 --set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}" \
82 --prefix PATH ':' ${pathAdditions}
84 mkdir -p "$out/vagrant-plugins/plugins.d"
85 echo '{}' > "$out/vagrant-plugins/plugins.json"
87 mkdir -p $out/share/bash-completion/completions/
88 cp -av contrib/bash/completion.sh $out/share/bash-completion/completions/vagrant
90 lib.optionalString withLibvirt ''
91 substitute ${./vagrant-libvirt.json.in} $out/vagrant-plugins/plugins.d/vagrant-libvirt.json \
92 --subst-var-by ruby_version ${ruby.version} \
93 --subst-var-by vagrant_version ${version}
96 installCheckPhase = ''
97 HOME="$(mktemp -d)" $out/bin/vagrant init --output - > /dev/null
100 # `patchShebangsAuto` patches this one script which is intended to run
101 # on foreign systems.
103 sed -i -e '1c#!/bin/sh -' \
104 $out/lib/ruby/gems/*/gems/vagrant-*/plugins/provisioners/salt/bootstrap-salt.sh
112 description = "A tool for building complete development environments";
113 homepage = "https://www.vagrantup.com/";
114 license = licenses.mit;
115 maintainers = with maintainers; [ ma27 ];
116 platforms = with platforms; linux ++ darwin;