vagrant: Build from source
This is not quite as elegant as using `bundlerApp`, which I could not get working. However, this still uses most of the Ruby infrastructure, including stock bundix, and should be fairly reasonable to maintain. This means no more hacks to work around wrong embedded binaries, and no need for an old version of Ruby. Note that `vagrant share` is no longer included, as that functionality is closed-source and not present in the upstream source code. The Vagrant maintainers publish official Vagrant installers, which they prefer people use as most platforms don't have great support for pinning known-good dependencies. When run outside one of the offical installers, Vagrant normally prints a warning to that effect. However, Vagrant does run outside the installer environment (nominally to support Vagrant development), and this has the effect of functioning better by respecting OS certs and shared libraries, as opposed to trying to use bundled versions. To keep these postive side effects without having to see the warning on every Vagrant invocation, patch out the call to print the warning. Note that I have reset the maintainers since the implementation is totally redone; I'm happy to re-add any of the current maintainers.
This commit is contained in:
@@ -1,141 +1,55 @@
|
||||
{ stdenv, fetchurl, fetchpatch, dpkg, curl, libarchive, openssl, rake, ruby, buildRubyGem, libiconv
|
||||
, libxml2, libxslt, libffi, makeWrapper, p7zip, xar, gzip, cpio }:
|
||||
{ lib, fetchurl, buildRubyGem, bundlerEnv, ruby }:
|
||||
|
||||
let
|
||||
version = "2.0.1";
|
||||
url = "https://github.com/hashicorp/vagrant/archive/v${version}.tar.gz";
|
||||
sha256 = "1fjfl00n4rsq6khypm56g0vq6l153q128r35zky2ba30bz292ar1";
|
||||
|
||||
url = if stdenv.isLinux
|
||||
then "https://releases.hashicorp.com/vagrant/${version}/vagrant_${version}_${arch}.deb"
|
||||
else if stdenv.isDarwin
|
||||
then "https://releases.hashicorp.com/vagrant/${version}/vagrant_${version}_${arch}.dmg"
|
||||
else "system ${stdenv.system} not supported";
|
||||
deps = bundlerEnv rec {
|
||||
name = "${pname}-${version}";
|
||||
pname = "vagrant";
|
||||
inherit version;
|
||||
|
||||
sha256 = {
|
||||
"x86_64-linux" = "0kyqchjsy747vbvhqiynz81kik8g0xqpkv70rz7hyr9x7fl9i51g";
|
||||
"i686-linux" = "0p3xhxy6shkd0393wjyj8qycdn3zqv60vnyz1b6zclz0kfah07zs";
|
||||
"x86_64-darwin" = "01hr5j9k31hsdlcwv3srzk0lphd8w0n9z95jvfkschdyjm9clpwm";
|
||||
}."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
|
||||
inherit ruby;
|
||||
gemdir = ./.;
|
||||
gemset = lib.recursiveUpdate (import ./gemset.nix) {
|
||||
vagrant = {
|
||||
source = {
|
||||
type = "url";
|
||||
inherit url sha256;
|
||||
};
|
||||
inherit version;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
arch = builtins.replaceStrings ["-linux" "-darwin"] ["" ""] stdenv.system;
|
||||
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "vagrant-${version}";
|
||||
in buildRubyGem rec {
|
||||
name = "${gemName}-${version}";
|
||||
gemName = "vagrant";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
inherit url sha256;
|
||||
doCheck = true;
|
||||
dontBuild = false;
|
||||
src = fetchurl { inherit url sha256; };
|
||||
|
||||
patches = [
|
||||
./unofficial-installation-nowarn.patch
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram "$out/bin/vagrant" \
|
||||
--set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit ruby deps;
|
||||
};
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
meta = with lib; {
|
||||
description = "A tool for building complete development environments";
|
||||
homepage = http://vagrantup.com;
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ lovek323 globin jgeerds kamilchm ];
|
||||
platforms = with platforms; linux ++ darwin;
|
||||
homepage = https://www.vagrantup.com/;
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ aneeshusa ];
|
||||
platforms = with platforms; linux ++ darwin;
|
||||
};
|
||||
|
||||
buildInputs = [ makeWrapper ]
|
||||
++ stdenv.lib.optional stdenv.isDarwin [ p7zip xar gzip cpio ];
|
||||
|
||||
unpackPhase = if stdenv.isLinux
|
||||
then ''
|
||||
${dpkg}/bin/dpkg-deb -x "$src" .
|
||||
''
|
||||
else ''
|
||||
7z x $src
|
||||
cd Vagrant/
|
||||
xar -xf Vagrant.pkg
|
||||
cd core.pkg/
|
||||
cat Payload | gzip -d - | cpio -id
|
||||
|
||||
# move unpacked directories to match unpacked .deb from linux,
|
||||
# so installPhase can be shared
|
||||
mkdir -p opt/vagrant/ usr/
|
||||
mv embedded opt/vagrant/embedded
|
||||
mv bin usr/bin
|
||||
'';
|
||||
|
||||
buildPhase = "";
|
||||
|
||||
installPhase = ''
|
||||
sed -i "s|/opt|$out/opt|" usr/bin/vagrant
|
||||
|
||||
# overwrite embedded binaries
|
||||
|
||||
# curl: curl, curl-config
|
||||
rm opt/vagrant/embedded/bin/{curl,curl-config}
|
||||
ln -s ${curl.bin}/bin/curl opt/vagrant/embedded/bin
|
||||
ln -s ${curl.dev}/bin/curl-config opt/vagrant/embedded/bin
|
||||
|
||||
# libarchive: bsdtar, bsdcpio
|
||||
rm opt/vagrant/embedded/lib/libarchive*
|
||||
ln -s ${libarchive}/lib/libarchive.so opt/vagrant/embedded/lib/libarchive.so
|
||||
rm opt/vagrant/embedded/bin/{bsdtar,bsdcpio}
|
||||
ln -s ${libarchive}/bin/bsdtar opt/vagrant/embedded/bin
|
||||
ln -s ${libarchive}/bin/bsdcpio opt/vagrant/embedded/bin
|
||||
|
||||
# openssl: c_rehash, openssl
|
||||
rm opt/vagrant/embedded/bin/{c_rehash,openssl}
|
||||
ln -s ${openssl.bin}/bin/c_rehash opt/vagrant/embedded/bin
|
||||
ln -s ${openssl.bin}/bin/openssl opt/vagrant/embedded/bin
|
||||
|
||||
# libiconv: iconv
|
||||
rm opt/vagrant/embedded/bin/iconv
|
||||
ln -s ${libiconv}/bin/iconv opt/vagrant/embedded/bin
|
||||
|
||||
# libxml: xml2-config, xmlcatalog, xmllint
|
||||
rm opt/vagrant/embedded/bin/{xml2-config,xmlcatalog,xmllint}
|
||||
ln -s ${libxml2.dev}/bin/xml2-config opt/vagrant/embedded/bin
|
||||
ln -s ${libxml2.bin}/bin/xmlcatalog opt/vagrant/embedded/bin
|
||||
ln -s ${libxml2.bin}/bin/xmllint opt/vagrant/embedded/bin
|
||||
|
||||
# libxslt: xslt-config, xsltproc
|
||||
rm opt/vagrant/embedded/bin/{xslt-config,xsltproc}
|
||||
ln -s ${libxslt.dev}/bin/xslt-config opt/vagrant/embedded/bin
|
||||
ln -s ${libxslt.bin}/bin/xsltproc opt/vagrant/embedded/bin
|
||||
|
||||
'' + (stdenv.lib.optionalString (! stdenv.isDarwin) ''
|
||||
# ruby: erb, gem, irb, rake, rdoc, ri, ruby
|
||||
rm opt/vagrant/embedded/bin/{erb,gem,irb,rake,rdoc,ri,ruby}
|
||||
ln -s ${ruby}/bin/erb opt/vagrant/embedded/bin
|
||||
ln -s ${ruby}/bin/gem opt/vagrant/embedded/bin
|
||||
ln -s ${ruby}/bin/irb opt/vagrant/embedded/bin
|
||||
ln -s ${rake}/bin/rake opt/vagrant/embedded/bin
|
||||
ln -s ${ruby}/bin/rdoc opt/vagrant/embedded/bin
|
||||
ln -s ${ruby}/bin/ri opt/vagrant/embedded/bin
|
||||
ln -s ${ruby}/bin/ruby opt/vagrant/embedded/bin
|
||||
|
||||
# ruby libs
|
||||
rm -rf opt/vagrant/embedded/lib/*
|
||||
for lib in ${ruby}/lib/*; do
|
||||
ln -s $lib opt/vagrant/embedded/lib/''${lib##*/}
|
||||
done
|
||||
|
||||
# libffi
|
||||
ln -s ${libffi}/lib/libffi.so.6 opt/vagrant/embedded/lib/libffi.so.6
|
||||
|
||||
'') + ''
|
||||
mkdir -p "$out"
|
||||
cp -r opt "$out"
|
||||
cp -r usr/bin "$out"
|
||||
wrapProgram "$out/bin/vagrant" --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [ libxml2 libxslt ]}" \
|
||||
--prefix LD_LIBRARY_PATH : "$out/opt/vagrant/embedded/lib"
|
||||
|
||||
install -D "opt/vagrant/embedded/gems/gems/vagrant-$version/contrib/bash/completion.sh" \
|
||||
"$out/share/bash-completion/completions/vagrant"
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
# 'hide' the template file from shebang-patching
|
||||
chmod -x "$out/opt/vagrant/embedded/gems/gems/vagrant-$version/plugins/provisioners/salt/bootstrap-salt.sh"
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
chmod +x "$out/opt/vagrant/embedded/gems/gems/vagrant-$version/plugins/provisioners/salt/bootstrap-salt.sh"
|
||||
'' +
|
||||
(stdenv.lib.optionalString stdenv.isDarwin ''
|
||||
# undo the directory movement done in unpackPhase
|
||||
mv $out/opt/vagrant/embedded $out/
|
||||
rm -r $out/opt
|
||||
'');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user