2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive
|
2021-03-09 03:18:52 +00:00
|
|
|
, libguestfs, qemu, writeText, withLibvirt ? stdenv.isLinux
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# NOTE: bumping the version and updating the hash is insufficient;
|
|
|
|
# you must use bundix to generate a new gemset.nix in the Vagrant source.
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "2.3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
url = "https://github.com/hashicorp/vagrant/archive/v${version}.tar.gz";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-+oqWMZqnuf9fSpkbd8vzf1SVSdhHN2JLzr76jyAEv0U=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
deps = bundlerEnv rec {
|
|
|
|
name = "${pname}-${version}";
|
|
|
|
pname = "vagrant";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
inherit ruby;
|
|
|
|
gemfile = writeText "Gemfile" "";
|
|
|
|
lockfile = writeText "Gemfile.lock" "";
|
|
|
|
gemset = lib.recursiveUpdate (import ./gemset.nix) ({
|
|
|
|
vagrant = {
|
|
|
|
source = {
|
|
|
|
type = "url";
|
2024-01-02 11:29:13 +00:00
|
|
|
inherit url hash;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
inherit version;
|
|
|
|
};
|
|
|
|
} // lib.optionalAttrs withLibvirt (import ./gemset_libvirt.nix));
|
|
|
|
|
|
|
|
# This replaces the gem symlinks with directories, resolving this
|
|
|
|
# error when running vagrant (I have no idea why):
|
|
|
|
# /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)
|
|
|
|
postBuild = ''
|
|
|
|
for gem in "$out"/lib/ruby/gems/*/gems/*; do
|
|
|
|
cp -a "$gem/" "$gem.new"
|
|
|
|
rm "$gem"
|
2021-02-05 17:12:51 +00:00
|
|
|
# needed on macOS, otherwise the mv yields permission denied
|
2020-04-24 23:36:52 +00:00
|
|
|
chmod +w "$gem.new"
|
|
|
|
mv "$gem.new" "$gem"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in buildRubyGem rec {
|
|
|
|
name = "${gemName}-${version}";
|
|
|
|
gemName = "vagrant";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
dontBuild = false;
|
2024-01-02 11:29:13 +00:00
|
|
|
src = fetchurl { inherit url hash; };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
./unofficial-installation-nowarn.patch
|
|
|
|
./use-system-bundler-version.patch
|
|
|
|
./0004-Support-system-installed-plugins.patch
|
2021-04-05 15:23:46 +00:00
|
|
|
./0001-Revert-Merge-pull-request-12225-from-chrisroberts-re.patch
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace lib/vagrant/plugin/manager.rb --subst-var-by \
|
|
|
|
system_plugin_dir "$out/vagrant-plugins"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# PATH additions:
|
|
|
|
# - libarchive: Make `bsdtar` available for extracting downloaded boxes
|
|
|
|
# withLibvirt only:
|
|
|
|
# - libguestfs: Make 'virt-sysprep' available for 'vagrant package'
|
|
|
|
# - qemu: Make 'qemu-img' available for 'vagrant package'
|
|
|
|
postInstall =
|
|
|
|
let
|
|
|
|
pathAdditions = lib.makeSearchPath "bin"
|
|
|
|
(map (x: lib.getBin x) ([
|
|
|
|
libarchive
|
|
|
|
] ++ lib.optionals withLibvirt [
|
|
|
|
libguestfs
|
|
|
|
qemu
|
|
|
|
]));
|
|
|
|
in ''
|
|
|
|
wrapProgram "$out/bin/vagrant" \
|
|
|
|
--set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}" \
|
2023-05-24 13:37:59 +00:00
|
|
|
--prefix PATH ':' ${pathAdditions} \
|
|
|
|
--set-default VAGRANT_CHECKPOINT_DISABLE 1
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
mkdir -p "$out/vagrant-plugins/plugins.d"
|
|
|
|
echo '{}' > "$out/vagrant-plugins/plugins.json"
|
|
|
|
|
|
|
|
mkdir -p $out/share/bash-completion/completions/
|
|
|
|
cp -av contrib/bash/completion.sh $out/share/bash-completion/completions/vagrant
|
|
|
|
'' +
|
|
|
|
lib.optionalString withLibvirt ''
|
|
|
|
substitute ${./vagrant-libvirt.json.in} $out/vagrant-plugins/plugins.d/vagrant-libvirt.json \
|
|
|
|
--subst-var-by ruby_version ${ruby.version} \
|
|
|
|
--subst-var-by vagrant_version ${version}
|
|
|
|
'';
|
|
|
|
|
|
|
|
installCheckPhase = ''
|
|
|
|
HOME="$(mktemp -d)" $out/bin/vagrant init --output - > /dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit ruby deps;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A tool for building complete development environments";
|
|
|
|
homepage = "https://www.vagrantup.com/";
|
|
|
|
license = licenses.mit;
|
2023-03-04 12:14:45 +00:00
|
|
|
maintainers = with maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = with platforms; linux ++ darwin;
|
|
|
|
};
|
|
|
|
}
|