Merge pull request #19402 from ryanartecona/vagrant/darwin-support

vagrant: add darwin support
This commit is contained in:
Daiderd Jordan 2016-10-15 00:37:13 +02:00 committed by GitHub
commit 9237596519

View File

@ -1,7 +1,5 @@
{ stdenv, fetchurl, fetchpatch, dpkg, curl, libarchive, openssl, ruby, buildRubyGem, libiconv { stdenv, fetchurl, fetchpatch, dpkg, curl, libarchive, openssl, ruby, buildRubyGem, libiconv
, libxml2, libxslt, makeWrapper }: , libxml2, libxslt, makeWrapper, p7zip, xar, gzip, cpio }:
assert stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux";
let let
version = "1.8.6"; version = "1.8.6";
@ -12,9 +10,16 @@ let
sha256 = "1rn03rqlf1iv6n87a78hkda2yqparhhaivfjpizblmxvlw2hk5r8"; sha256 = "1rn03rqlf1iv6n87a78hkda2yqparhhaivfjpizblmxvlw2hk5r8";
}; };
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}.dmg"
else "system ${stdenv.system} not supported";
sha256 = { sha256 = {
"x86_64-linux" = "1nkhf160hcl02yvafj6hq53j204qqxyvxjngnmf4f5md8dmkpn76"; "x86_64-linux" = "1nkhf160hcl02yvafj6hq53j204qqxyvxjngnmf4f5md8dmkpn76";
"i686-linux" = "0mr4pn7nggjdsqyxh1z2mflvvmpzhbxh5gax501d2hi8xr0y68df"; "i686-linux" = "0mr4pn7nggjdsqyxh1z2mflvvmpzhbxh5gax501d2hi8xr0y68df";
"x86_64-darwin" = "1nd2adxwhs2vwmi5vw2z720ny4q9rpj8i4dlcdxzbyli7h8cs5mr";
}."${stdenv.system}" or (throw "system ${stdenv.system} not supported"); }."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
arch = builtins.replaceStrings ["-linux"] [""] stdenv.system; arch = builtins.replaceStrings ["-linux"] [""] stdenv.system;
@ -24,8 +29,7 @@ in stdenv.mkDerivation rec {
inherit version; inherit version;
src = fetchurl { src = fetchurl {
url = "https://releases.hashicorp.com/vagrant/${version}/vagrant_${version}_${arch}.deb"; inherit url sha256;
inherit sha256;
}; };
meta = with stdenv.lib; { meta = with stdenv.lib; {
@ -33,14 +37,29 @@ in stdenv.mkDerivation rec {
homepage = http://vagrantup.com; homepage = http://vagrantup.com;
license = licenses.mit; license = licenses.mit;
maintainers = with maintainers; [ lovek323 globin jgeerds kamilchm ]; maintainers = with maintainers; [ lovek323 globin jgeerds kamilchm ];
platforms = platforms.linux; platforms = with platforms; linux ++ darwin;
}; };
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ]
++ stdenv.lib.optional stdenv.isDarwin [ p7zip xar gzip cpio ];
unpackPhase = '' unpackPhase = if stdenv.isLinux
${dpkg}/bin/dpkg-deb -x "$src" . 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 = ""; buildPhase = "";
@ -110,5 +129,10 @@ in stdenv.mkDerivation rec {
postFixup = '' postFixup = ''
chmod +x "$out/opt/vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/templates/Executable" chmod +x "$out/opt/vagrant/embedded/gems/gems/bundler-1.12.5/lib/bundler/templates/Executable"
chmod +x "$out/opt/vagrant/embedded/gems/gems/vagrant-$version/plugins/provisioners/salt/bootstrap-salt.sh" 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
'');
} }