Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vagrant_libvirt: init at 1.9.5 #26202

Closed
wants to merge 6 commits into from

Conversation

proteansec
Copy link
Contributor

Motivation for this change

First of all, this is not ready to merge. Basically, I would like to package vagrant building it by source, but also enable vagrant-libvirt plugin. Hopefully, this will also provide the means to install other vagrant plugins easily.

The reason for adding additional flags (gemflags) is needed, because the libvirt dependency cannot be found otherwise. The libvirt is specified in buildInputs, but even though I've specified it in build inputs, I'm getting the following error when trying to build without the additional flags ("--with-libvirt-include=${libvirt}/include --with-libvirt-lib=${libvirt}/lib").

# nix-build $NIXPKGS -A vagrant_libvirt ~/nixpkgs
these derivations will be built:
/nix/store/ryw2v1y81sx4pgk1zzyjw99xv1dzalin-ruby2.2.7-nokogiri-1.6.8.1.drv
/nix/store/wc3s363wcffsaljz9p21w73gd85w1v50-ruby2.2.7-ruby-libvirt-0.7.0.drv
/nix/store/ng5245g1aap0vqyjazxhjkycgf8012vv-vagrant-1.9.5.drv
/nix/store/49xqd3b6zk6wa3sqd3bby6gzcy9j4v76-vagrant-1.9.5.drv
building path(s) ‘/nix/store/yz8v38hnvi90ghx9gzz1pw8c9cfcfbpp-ruby2.2.7-nokogiri-1.6.8.1’
building path(s) ‘/nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0’
unpacking sources
patching sources
installing
buildFlags:
unpacking sources
patching sources
installing
buildFlags:
WARNING: You build with buildroot.
Build root: /
Bin dir: /nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0/lib/ruby/gems/2.2.0/bin
Gem home: /nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0/lib/ruby/gems/2.2.0
Building native extensions. This could take a while...
ERROR: Error installing /nix/store/r5rwji0z9r53smhf782mj06pvznp9qrg-ruby-libvirt-0.7.0.gem:
ERROR: Failed to build gem native extension.
current directory: /nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0/lib/ruby/gems/2.2.0/gems/ruby-libvirt-0.7.0/ext/libvirt
/nix/store/05bdj1hkav8mlma6y2dr5yqqdvppz2b4-ruby-2.2.7/bin/ruby -r ./siteconf20170528-76-ccyag1.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/nix/store/05bdj1hkav8mlma6y2dr5yqqdvppz2b4-ruby-2.2.7/bin/$(RUBY_BASE_NAME)
--with-libvirt-include
--without-libvirt-include
--with-libvirt-lib
--without-libvirt-lib
--with-libvirt-config
--without-libvirt-config
--with-pkg-config
--without-pkg-config
extconf.rb:73:in `

': libvirt library not found in default locations (RuntimeError)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/ruby-libvirt-0.7.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0/lib/ruby/gems/2.2.0/gems/ruby-libvirt-0.7.0 for inspection.
Results logged to /nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/ruby-libvirt-0.7.0/gem_make.out
WARNING: You build with buildroot.
Build root: /
Bin dir: /nix/store/yz8v38hnvi90ghx9gzz1pw8c9cfcfbpp-ruby2.2.7-nokogiri-1.6.8.1/lib/ruby/gems/2.2.0/bin
Gem home: /nix/store/yz8v38hnvi90ghx9gzz1pw8c9cfcfbpp-ruby2.2.7-nokogiri-1.6.8.1/lib/ruby/gems/2.2.0
builder for ‘/nix/store/wc3s363wcffsaljz9p21w73gd85w1v50-ruby2.2.7-ruby-libvirt-0.7.0.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/ng5245g1aap0vqyjazxhjkycgf8012vv-vagrant-1.9.5.drv’: 1 dependencies couldn't be built
cannot build derivation ‘/nix/store/49xqd3b6zk6wa3sqd3bby6gzcy9j4v76-vagrant-1.9.5.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/49xqd3b6zk6wa3sqd3bby6gzcy9j4v76-vagrant-1.9.5.drv’ failed

# cat /nix/store/y84jn8wc4hwkk2037fbir8bs282lyq7q-ruby2.2.7-ruby-libvirt-0.7.0/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/ruby-libvirt-0.7.0/mkmf.log
package configuration for libvirt is not found

I'm having problems with the existing code, since nokogiri is unable to build, since it's missing the mini_portile2 dependency, even though it is properly specified and should be installed into the environment:

# nix-build $NIXPKGS -A vagrant_libvirt ~/nixpkgs
these derivations will be built:
/nix/store/6iddalqkqc45g2q240q1v86zmsixzjd0-ruby2.3.4-nokogiri-1.6.8.1.drv
/nix/store/zb64gaqncaql93rkb8ayw8ad30wjf74y-vagrant-1.9.5.drv
/nix/store/zgc95d4db52qbrvpsanw9wdxcm9cxszv-vagrant-1.9.5.drv
these paths will be fetched (0.02 MiB download, 0.08 MiB unpacked):
/nix/store/bp4kwbvnddpap3y80f8lzrk7giyb104x-libarchive-3.3.1-dev
fetching path ‘/nix/store/bp4kwbvnddpap3y80f8lzrk7giyb104x-libarchive-3.3.1-dev’...
building path(s) ‘/nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1’
unpacking sources
patching sources
installing
buildFlags: --with-libvirt-include=/nix/store/8w7f944zbsbcj4hjq7siq467hgf4cil2-libvirt-3.1.0/include --with-libvirt-lib=/nix/store/8w7f944zbsbcj4hjq7siq467hgf4cil2-libvirt-3.1.0/lib

*** Downloading ‘https://cache.nixos.org/nar/0czngvcpniaf11ar3pm6kw7b8mgji05dag4pa3ji28y3j1frdp7g.nar.xz’ (signed by ‘cache.nixos.org-1’) to ‘/nix/store/bp4kwbvnddpap3y80f8lzrk7giyb104x-libarchive-3.3.1-dev’...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 18216 100 18216 0 0 95492 0 --:--:-- --:--:-- --:--:-- 96893

WARNING: You build with buildroot.
Build root: /
Bin dir: /nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0/bin
Gem home: /nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0
Building native extensions with: '--with-libvirt-include=/nix/store/8w7f944zbsbcj4hjq7siq467hgf4cil2-libvirt-3.1.0/include --with-libvirt-lib=/nix/store/8w7f944zbsbcj4hjq7siq467hgf4cil2-libvirt-3.1.0/lib'
This could take a while...
ERROR: Error installing /nix/store/1qgb1nrj6f8d11cvrmjv5wcq6l2qrky3-nokogiri-1.6.8.1.gem:
ERROR: Failed to build gem native extension.

current directory: /nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/ext/nokogiri

/nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/bin/ruby -r ./siteconf20170529-76-5ujpzt.rb extconf.rb --with-libvirt-include=/nix/store/8w7f944zbsbcj4hjq7siq467hgf4cil2-libvirt-3.1.0/include --with-libvirt-lib=/nix/store/8w7f944zbsbcj4hjq7siq467hgf4cil2-libvirt-3.1.0/lib
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:308:in to_specs': Could not find 'mini_portile2' (~> 2.1.0) among 5 total gem(s) (Gem::MissingSpecError) Checked in 'GEM_PATH=/nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/lib/ruby/gems/2.3.0:/nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0', execute gem envfor more information from /nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb:320:into_spec'
from /nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in gem' from extconf.rb:468:in

'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1 for inspection.
Results logged to /nix/store/zx4njlnyqz835s2drziwgqmn8698hhmx-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8.1/gem_make.out
builder for ‘/nix/store/6iddalqkqc45g2q240q1v86zmsixzjd0-ruby2.3.4-nokogiri-1.6.8.1.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/zb64gaqncaql93rkb8ayw8ad30wjf74y-vagrant-1.9.5.drv’: 1 dependencies couldn't be built
cannot build derivation ‘/nix/store/zgc95d4db52qbrvpsanw9wdxcm9cxszv-vagrant-1.9.5.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/zgc95d4db52qbrvpsanw9wdxcm9cxszv-vagrant-1.9.5.drv’ failed

I would like to know if something has any ideas how to make this work.

@mention-bot
Copy link

@proteansec, thanks for your PR! By analyzing the history of the files in this pull request, we identified @cstrahan, @zimbatm and @abbradar to be potential reviewers.

@Mic92
Copy link
Member

Mic92 commented Jun 3, 2017

You need an override for the ruby-libvirt gem in nixpkgs/pkgs/development/ruby-modules/gem-config/default.nix and add libvirt as buildInput so it can be used to build the gem.

@proteansec
Copy link
Contributor Author

@Mic92 I tried adding the ruby-libvirt into the default.nix that you've mentioned, but it's not being picked up. You can see the output here:

# nix-build $NIXPKGS -A vagrant_libvirt ~/nixpkgs
these derivations will be built:
/nix/store/3c1lsfpnkp968d05i48xcqk28gbl8kh3-ruby2.3.4-ruby-libvirt-0.7.0.drv
/nix/store/nin6m2120jachan2205n9rnjj7fb8n0w-ruby2.3.4-json-2.1.0.drv
/nix/store/rdjllqjvmkmmwwwl2z49s8bw23bfknyh-ruby2.3.4-nokogiri-1.6.8.1.drv
/nix/store/br3pign943f499ilia9vc4r7zq7s5bxx-vagrant-1.9.5.drv
/nix/store/826pw4mr12p369cqvc1irm4jcbvyrbkr-vagrant-1.9.5.drv
building path(s) ‘/nix/store/i9b7kdbb37m6aqlqmlmybl8zc0y0pssj-ruby2.3.4-json-2.1.0’
building path(s) ‘/nix/store/0mxxw2g04krdl0q6m6sq7gaybxk4wz9k-ruby2.3.4-nokogiri-1.6.8.1’
building path(s) ‘/nix/store/2zgdnb1a0ayrimh233xc8z5dfk82qhak-ruby2.3.4-ruby-libvirt-0.7.0’
unpacking sources
patching sources
installing
unpacking sources
buildFlags:
patching sources
installing
buildFlags:
unpacking sources
patching sources
installing
buildFlags:
WARNING: You build with buildroot.
Build root: /
Bin dir: /nix/store/i9b7kdbb37m6aqlqmlmybl8zc0y0pssj-ruby2.3.4-json-2.1.0/lib/ruby/gems/2.3.0/bin
Gem home: /nix/store/i9b7kdbb37m6aqlqmlmybl8zc0y0pssj-ruby2.3.4-json-2.1.0/lib/ruby/gems/2.3.0
Building native extensions. This could take a while...
WARNING: You build with buildroot.
Build root: /
Bin dir: /nix/store/2zgdnb1a0ayrimh233xc8z5dfk82qhak-ruby2.3.4-ruby-libvirt-0.7.0/lib/ruby/gems/2.3.0/bin
Gem home: /nix/store/2zgdnb1a0ayrimh233xc8z5dfk82qhak-ruby2.3.4-ruby-libvirt-0.7.0/lib/ruby/gems/2.3.0
Building native extensions. This could take a while...
WARNING: You build with buildroot.
Build root: /
Bin dir: /nix/store/0mxxw2g04krdl0q6m6sq7gaybxk4wz9k-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0/bin
Gem home: /nix/store/0mxxw2g04krdl0q6m6sq7gaybxk4wz9k-ruby2.3.4-nokogiri-1.6.8.1/lib/ruby/gems/2.3.0
ERROR: Error installing /nix/store/r5rwji0z9r53smhf782mj06pvznp9qrg-ruby-libvirt-0.7.0.gem:
ERROR: Failed to build gem native extension.

current directory: /nix/store/2zgdnb1a0ayrimh233xc8z5dfk82qhak-ruby2.3.4-ruby-libvirt-0.7.0/lib/ruby/gems/2.3.0/gems/ruby-libvirt-0.7.0/ext/libvirt
/nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/bin/ruby -r ./siteconf20170605-80-49h8am.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/nix/store/w7dalxpjpz82d20b3xpndr8rrxrizis9-ruby-2.3.4/bin/$(RUBY_BASE_NAME)
--with-libvirt-include
--without-libvirt-include
--with-libvirt-lib
--without-libvirt-lib
--with-libvirt-config
--without-libvirt-config
--with-pkg-config
--without-pkg-config
extconf.rb:73:in `

': libvirt library not found in default locations (RuntimeError)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/nix/store/2zgdnb1a0ayrimh233xc8z5dfk82qhak-ruby2.3.4-ruby-libvirt-0.7.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/ruby-libvirt-0.7.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /nix/store/2zgdnb1a0ayrimh233xc8z5dfk82qhak-ruby2.3.4-ruby-libvirt-0.7.0/lib/ruby/gems/2.3.0/gems/ruby-libvirt-0.7.0 for inspection.
Results logged to /nix/store/2zgdnb1a0ayrimh233xc8z5dfk82qhak-ruby2.3.4-ruby-libvirt-0.7.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/ruby-libvirt-0.7.0/gem_make.out
builder for ‘/nix/store/3c1lsfpnkp968d05i48xcqk28gbl8kh3-ruby2.3.4-ruby-libvirt-0.7.0.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/br3pign943f499ilia9vc4r7zq7s5bxx-vagrant-1.9.5.drv’: 1 dependencies couldn't be built
cannot build derivation ‘/nix/store/826pw4mr12p369cqvc1irm4jcbvyrbkr-vagrant-1.9.5.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/826pw4mr12p369cqvc1irm4jcbvyrbkr-vagrant-1.9.5.drv’ failed

Would you be kind enough to look at the commit and let me know if there's anything out of ordinary in there, so the ruby-libvirt dependency is not being passed the correct parameters.

@Mic92
Copy link
Member

Mic92 commented Jun 10, 2017

ruby-libvirt is now fixed.

src = fetchurl {
url = "https://github.com/mitchellh/vagrant/archive/v${version}.tar.gz";
sha256 = "0ancxh93ziyjak1wvjnbg2x7jv1brgbd4pxyi51zkdj867g8xsv9";
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it not possible to extend vagrant instead of packaging it again?

"--with-libvirt-lib=${libvirt}/lib"
];
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bit could already be merged regardless of the rest

@proteansec
Copy link
Contributor Author

proteansec commented Jun 10, 2017

I've modified the package,so the wrapper now provides the installed dependent gems to vagrant, while the build succeeds now. However, when running vagrant, it complains about vagrant not being found.

# /nix/store/czcw4vy3njyqa0aqvydn0rgw1dkhz41d-vagrant-1.9.5/bin/vagrant ~/nixpkgs
/nix/store/bgblhgkpb4aygvym0aa450yniacy12jk-ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- vagrant (LoadError) from /nix/store/bgblhgkpb4aygvym0aa450yniacy12jk-ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /nix/store/czcw4vy3njyqa0aqvydn0rgw1dkhz41d-vagrant-1.9.5/bin/.vagrant-wrapped:62:in '<main>'

The error comes from /nix/store/czcw4vy3njyqa0aqvydn0rgw1dkhz41d-vagrant-1.9.5/bin/.vagrant-wrapped, which includes the following lines. The script can find log4r, but cannot find vagrant and it fails there.

require 'log4r'
require 'vagrant'
require 'vagrant/bundler'
require 'vagrant/cli'
require 'vagrant/util/platform'

@zimbatm, building from source is a lot nicer than using the package that has already been build. Hopefully, we can merge the new version of vagrant (once working), which builds from source, and remove the old version from nixpkgs.

@zimbatm @Mic92 Any ideas how to resolve the final issue, so we can finally make this work and possibly merge into nixpkgs.

@proteansec
Copy link
Contributor Author

@zimbatm @Mic92 Does anybody have any ideas on how to resolve the final issues of this, so I can finish the implementation and merge the code.

@globin
Copy link
Member

globin commented Dec 17, 2018

This has been superseded by the PRs in the references above.

@globin globin closed this Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants