1 { stdenv, lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive
2 , libguestfs, qemu, writeText, withLibvirt ? stdenv.isLinux
7 # NOTE: bumping the version and updating the hash is insufficient;
8 # you must use bundix to generate a new gemset.nix in the Vagrant source.
10 url = "https://github.com/hashicorp/vagrant/archive/v${version}.tar.gz";
11 hash = "sha256-Gc+jBuP/rl3b8wUE9hoaMSSqmodyGxMKFAmNTqH+v4k=";
13 deps = bundlerEnv rec {
14 name = "${pname}-${version}";
19 gemfile = writeText "Gemfile" "";
20 lockfile = writeText "Gemfile.lock" "";
21 gemset = lib.recursiveUpdate (import ./gemset.nix) ({
29 } // lib.optionalAttrs withLibvirt (import ./gemset_libvirt.nix));
31 # This replaces the gem symlinks with directories, resolving this
32 # error when running vagrant (I have no idea why):
33 # /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)
35 for gem in "$out"/lib/ruby/gems/*/gems/*; do
36 cp -a "$gem/" "$gem.new"
38 # needed on macOS, otherwise the mv yields permission denied
46 name = "${gemName}-${version}";
50 doInstallCheck = true;
52 src = fetchurl { inherit url hash; };
54 # Some reports indicate that some connection types, particularly
55 # WinRM, suffer from "Digest initialization failed" errors. Adding
56 # openssl as a build input resolves this runtime error.
57 buildInputs = [ openssl ];
60 ./unofficial-installation-nowarn.patch
61 ./use-system-bundler-version.patch
62 ./0004-Support-system-installed-plugins.patch
63 ./0001-Revert-Merge-pull-request-12225-from-chrisroberts-re.patch
67 substituteInPlace lib/vagrant/plugin/manager.rb --subst-var-by \
68 system_plugin_dir "$out/vagrant-plugins"
72 # - libarchive: Make `bsdtar` available for extracting downloaded boxes
74 # - libguestfs: Make 'virt-sysprep' available for 'vagrant package'
75 # - qemu: Make 'qemu-img' available for 'vagrant package'
78 pathAdditions = lib.makeSearchPath "bin"
79 (map (x: lib.getBin x) ([
81 ] ++ lib.optionals withLibvirt [
86 wrapProgram "$out/bin/vagrant" \
87 --set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}" \
88 --prefix PATH ':' ${pathAdditions} \
89 --set-default VAGRANT_CHECKPOINT_DISABLE 1
91 mkdir -p "$out/vagrant-plugins/plugins.d"
92 echo '{}' > "$out/vagrant-plugins/plugins.json"
94 # install bash completion
95 mkdir -p $out/share/bash-completion/completions/
96 cp -av contrib/bash/completion.sh $out/share/bash-completion/completions/vagrant
97 # install zsh completion
98 mkdir -p $out/share/zsh/site-functions/
99 cp -av contrib/zsh/_vagrant $out/share/zsh/site-functions/
101 lib.optionalString withLibvirt ''
102 substitute ${./vagrant-libvirt.json.in} $out/vagrant-plugins/plugins.d/vagrant-libvirt.json \
103 --subst-var-by ruby_version ${ruby.version} \
104 --subst-var-by vagrant_version ${version}
107 installCheckPhase = ''
108 HOME="$(mktemp -d)" $out/bin/vagrant init --output - > /dev/null
116 description = "A tool for building complete development environments";
117 homepage = "https://www.vagrantup.com/";
118 license = licenses.bsl11;
119 maintainers = with maintainers; [ tylerjl ];
120 platforms = with platforms; linux ++ darwin;