Skip to content

Commit

Permalink
vagrant: use libarchive lib from Nix (#17597)
Browse files Browse the repository at this point in the history
We currently already replace the embedded bsdtar binaries with the
corresponding ones from Nix. However, we also need to replace the
libarchive shared library to prevent version mismatches between the
embedded library and the Nix binaries.

Also expose version on the derivation and use environment variables
to make overriding the derivation easier.
  • Loading branch information
aneeshusa authored and fpletz committed Aug 9, 2016
1 parent cb54b19 commit 746b591
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkgs/development/tools/vagrant/default.nix
Expand Up @@ -15,6 +15,7 @@ let
in
stdenv.mkDerivation rec {
name = "vagrant-${version}";
inherit version;

src =
if stdenv.system == "x86_64-linux" then
Expand All @@ -39,10 +40,10 @@ stdenv.mkDerivation rec {
buildInputs = [ makeWrapper ];

unpackPhase = ''
${dpkg}/bin/dpkg-deb -x ${src} .
${dpkg}/bin/dpkg-deb -x "$src" .
'';

buildPhase = false;
buildPhase = "";

installPhase = ''
sed -i "s|/opt|$out/opt|" usr/bin/vagrant
Expand All @@ -55,6 +56,8 @@ stdenv.mkDerivation rec {
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
Expand Down Expand Up @@ -92,17 +95,17 @@ stdenv.mkDerivation rec {
mkdir -p "$out"
cp -r opt "$out"
cp -r usr/bin "$out"
wrapProgram $out/bin/vagrant --prefix LD_LIBRARY_PATH : $out/opt/vagrant/embedded/lib
wrapProgram "$out/bin/vagrant" --prefix LD_LIBRARY_PATH : "$out/opt/vagrant/embedded/lib"
'';

preFixup = ''
# 'hide' the template file from shebang-patching
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/bundler-1.12.5/lib/bundler/templates/Executable"
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/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/bundler-1.12.5/lib/bundler/templates/Executable"
chmod +x "$out/opt/vagrant/embedded/gems/gems/vagrant-$version/plugins/provisioners/salt/bootstrap-salt.sh"
'';
}

0 comments on commit 746b591

Please sign in to comment.