1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-04 19:45:54 +00:00
nixpkgs/pkgs/development/tools/vagrant/default.nix

98 lines
2.8 KiB
Nix
Raw Normal View History

{ stdenv, lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive
, libguestfs, qemu, writeText, withLibvirt ? stdenv.isLinux }:
2013-11-21 22:21:39 +00:00
2014-11-18 04:24:07 +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.
2019-02-11 23:22:19 +00:00
version = "2.2.3";
url = "https://github.com/hashicorp/vagrant/archive/v${version}.tar.gz";
2019-02-11 23:22:19 +00:00
sha256 = "1j00glqn8b1zsgqg2nyk5as405a6s6vclswg2ri0a229hnsiabvs";
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";
inherit url sha256;
};
inherit version;
};
} // lib.optionalAttrs withLibvirt (import ./gemset_libvirt.nix));
};
2014-11-18 04:24:07 +00:00
in buildRubyGem rec {
name = "${gemName}-${version}";
gemName = "vagrant";
inherit version;
doInstallCheck = true;
dontBuild = false;
src = fetchurl { inherit url sha256; };
patches = [
./use-system-bundler-version.patch
./0004-Support-system-installed-plugins.patch
];
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}" \
--prefix PATH ':' ${pathAdditions}
mkdir -p "$out/vagrant-plugins/plugins.d"
echo '{}' > "$out/vagrant-plugins/plugins.json"
'' +
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}
'';
2013-11-21 22:21:39 +00:00
installCheckPhase = ''
if [[ "$("$out/bin/vagrant" --version)" == "Vagrant ${version}" ]]; then
echo 'Vagrant smoke check passed'
else
echo 'Vagrant smoke check failed'
return 1
fi
'';
passthru = {
inherit ruby deps;
};
meta = with lib; {
2013-11-21 22:21:39 +00:00
description = "A tool for building complete development environments";
homepage = https://www.vagrantup.com/;
license = licenses.mit;
maintainers = with maintainers; [ aneeshusa ];
platforms = with platforms; linux ++ darwin;
2013-11-21 22:21:39 +00:00
};
}