git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #52413 from mat8913/vagrant-libvirt

vagrant: build and install vagrant-libvirt plugin

commitda093022a43c305a1c15fe645d36f3ba29b57db3 authorJörg Thalheim <Mic92@users.noreply.github.com> dateWed 19 Dec 2018, 12:18 (8 years ago) parent857853dc660f3d
5 files changed+236−16
pkgs/development/ruby-modules/gem-config/default.nix+9−1 pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch+97 pkgs/development/tools/vagrant/default.nix+16−9 pkgs/development/tools/vagrant/gemset_libvirt.nix+105−6 pkgs/development/tools/vagrant/vagrant-libvirt.json.in+9
pkgs/development/ruby-modules/gem-config/default.nix+9−1
@@ -23,7 +23,7 @@
2323, cmake, libssh2, openssl, mysql, darwin, git, perl, pcre, gecode_3, curl
2424, msgpack, qt59, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem
2525, cairo, re2, rake, gobject-introspection, gdk_pixbuf, zeromq, graphicsmagick, libcxx, file
26−, libselinux ? null, libsepol ? null
26+, libselinux ? null, libsepol ? null, libvirt
2727}@args:
2828
2929let
@@ -314,6 +314,14 @@ in
314314 buildInputs = [ imagemagick which ];
315315 };
316316
317+ ruby-libvirt = attrs: {
318+ buildInputs = [ libvirt pkgconfig ];
319+ buildFlags = [
320+ "--with-libvirt-include=${libvirt}/include"
321+ "--with-libvirt-lib=${libvirt}/lib"
322+ ];
323+ };
324+
317325 ruby-lxc = attrs: {
318326 buildInputs = [ lxc ];
319327 };
pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patchnew file+97
@@ -0,0 +1,97 @@
1+From: Antonio Terceiro <terceiro@debian.org>
2+Date: Wed, 27 May 2015 09:36:17 -0300
3+Subject: Support system-installed plugins
4+Source: https://salsa.debian.org/ruby-team/vagrant/blob/cb672c6dc0c63f6552c5ec4d6d7d22929d353503/debian/patches/0004-Support-system-installed-plugins.patch
5+
6+Plugins must be installed as regular Ruby libraries, and they must
7+contain /usr/share/vagrant-plugins/plugins.d/$PLUGINNAME.json with the
8+following content:
9+
10+{
11+ "${PLUGINNAME}": {
12+ "ruby_version":"$(ruby -e 'puts RUBY_VERSION')",
13+ "vagrant_version":"$(cat /usr/share/vagrant/version.txt)",
14+ "gem_version":"",
15+ "require":"",
16+ "sources":[]
17+ }
18+}
19+---
20+ lib/vagrant/plugin/manager.rb | 4 ++--
21+ lib/vagrant/plugin/state_file.rb | 22 +++++++++++++++++++++-
22+ 2 files changed, 23 insertions(+), 3 deletions(-)
23+
24+diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb
25+index 567347d..d9d76a0 100644
26+--- a/lib/vagrant/plugin/manager.rb
27++++ b/lib/vagrant/plugin/manager.rb
28+@@ -18,7 +18,7 @@ module Vagrant
29+
30+ # Returns the path to the [StateFile] for system plugins.
31+ def self.system_plugins_file
32+- dir = Vagrant.installer_embedded_dir
33++ dir = '@system_plugin_dir@'
34+ return nil if !dir
35+ Pathname.new(dir).join("plugins.json")
36+ end
37+@@ -38,7 +38,7 @@ module Vagrant
38+
39+ system_path = self.class.system_plugins_file
40+ @system_file = nil
41+- @system_file = StateFile.new(system_path) if system_path && system_path.file?
42++ @system_file = StateFile.new(system_path, true) if system_path && system_path.file?
43+
44+ @local_file = nil
45+ @globalized = @localized = false
46+diff --git a/lib/vagrant/plugin/state_file.rb b/lib/vagrant/plugin/state_file.rb
47+index c6872d4..935d431 100644
48+--- a/lib/vagrant/plugin/state_file.rb
49++++ b/lib/vagrant/plugin/state_file.rb
50+@@ -11,8 +11,9 @@ module Vagrant
51+ # @return [Pathname] path to file
52+ attr_reader :path
53+
54+- def initialize(path)
55++ def initialize(path, system = false)
56+ @path = path
57++ @system = system
58+
59+ @data = {}
60+ if @path.exist?
61+@@ -28,6 +29,21 @@ module Vagrant
62+
63+ @data["version"] ||= "1"
64+ @data["installed"] ||= {}
65++ load_extra_plugins
66++ end
67++
68++ def load_extra_plugins
69++ extra_plugins = Dir.glob(@path.dirname.join('plugins.d', '*.json'))
70++ extra_plugins.each do |filename|
71++ json = File.read(filename)
72++ begin
73++ plugin_data = JSON.parse(json)
74++ @data["installed"].merge!(plugin_data)
75++ rescue JSON::ParserError => e
76++ raise Vagrant::Errors::PluginStateFileParseError,
77++ path: filename, message: e.message
78++ end
79++ end
80+ end
81+
82+ # Add a plugin that is installed to the state file.
83+@@ -107,6 +123,14 @@ module Vagrant
84+ f.close
85+ FileUtils.mv(f.path, @path)
86+ end
87++ rescue Errno::EACCES
88++ # Ignore permission denied against system-installed plugins; regular
89++ # users are not supposed to write there.
90++ raise unless @system
91++ rescue Errno::EROFS
92++ # Ignore read-only filesystem against system-installed plugins; regular
93++ # users are not supposed to write there.
94++ raise unless @system
95+ end
96+
97+ protected
pkgs/development/tools/vagrant/default.nix+16−9
@@ -1,4 +1,4 @@
1−{ lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive, writeText, withLibvirt ? true, libvirt, pkgconfig }:
1+{ lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive, writeText, withLibvirt ? true}:
22
33let
44 # NOTE: bumping the version and updating the hash is insufficient;
@@ -35,24 +35,31 @@ in buildRubyGem rec {
3535 dontBuild = false;
3636 src = fetchurl { inherit url sha256; };
3737
38− buildInputs = lib.optional withLibvirt [ libvirt pkgconfig ];
39−
4038 patches = [
4139 ./unofficial-installation-nowarn.patch
4240 ./use-system-bundler-version.patch
41+ ./0004-Support-system-installed-plugins.patch
4342 ];
4443
44+ postPatch = ''
45+ substituteInPlace lib/vagrant/plugin/manager.rb --subst-var-by \
46+ system_plugin_dir "$out/vagrant-plugins"
47+ '';
48+
4549 # PATH additions:
4650 # - libarchive: Make `bsdtar` available for extracting downloaded boxes
4751 postInstall = ''
4852 wrapProgram "$out/bin/vagrant" \
4953 --set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}" \
50− --prefix PATH ':' "${lib.getBin libarchive}/bin" \
51− ${lib.optionalString withLibvirt ''
52− --prefix PATH ':' "${pkgconfig}/bin" \
53− --prefix PKG_CONFIG_PATH ':' \
54− "${lib.makeSearchPath "lib/pkgconfig" [ libvirt ]}"
55− ''}
54+ --prefix PATH ':' "${lib.getBin libarchive}/bin"
55+
56+ mkdir -p "$out/vagrant-plugins/plugins.d"
57+ echo '{}' > "$out/vagrant-plugins/plugins.json"
58+ '' +
59+ lib.optionalString withLibvirt ''
60+ substitute ${./vagrant-libvirt.json.in} $out/vagrant-plugins/plugins.d/vagrant-libvirt.json \
61+ --subst-var-by ruby_version ${ruby.version} \
62+ --subst-var-by vagrant_version ${version}
5663 '';
5764
5865 installCheckPhase = ''
pkgs/development/tools/vagrant/gemset_libvirt.nix+105−6
@@ -1,19 +1,118 @@
11{
2+ excon = {
3+ groups = ["default"];
4+ platforms = [];
5+ source = {
6+ remotes = ["https://rubygems.org"];
7+ sha256 = "15l9w0938c19nxmrp09n75qpmm64k12xj69h47yvxzcxcpbgnkb2";
8+ type = "gem";
9+ };
10+ version = "0.62.0";
11+ };
12+ fog-core = {
13+ dependencies = ["builder" "excon" "formatador"];
14+ groups = ["default"];
15+ platforms = [];
16+ source = {
17+ remotes = ["https://rubygems.org"];
18+ sha256 = "0ac25s2wv7m6av7h7vjzd2bg3srhnn5yrz3lq1xpimhnfmp82sw6";
19+ type = "gem";
20+ };
21+ version = "1.43.0";
22+ };
23+ fog-json = {
24+ dependencies = ["fog-core" "multi_json"];
25+ groups = ["default"];
26+ platforms = [];
27+ source = {
28+ remotes = ["https://rubygems.org"];
29+ sha256 = "1zj8llzc119zafbmfa4ai3z5s7c4vp9akfs0f9l2piyvcarmlkyx";
30+ type = "gem";
31+ };
32+ version = "1.2.0";
33+ };
34+ fog-libvirt = {
35+ dependencies = ["fog-core" "fog-json" "fog-xml" "json" "ruby-libvirt"];
36+ groups = ["default"];
37+ platforms = [];
38+ source = {
39+ remotes = ["https://rubygems.org"];
40+ sha256 = "0gk16gsjd51x71wla7h5jqr6x5ywpwz5l8jdv76f9mr6fp1j2bkf";
41+ type = "gem";
42+ };
43+ version = "0.5.0";
44+ };
45+ fog-xml = {
46+ dependencies = ["fog-core" "nokogiri"];
47+ groups = ["default"];
48+ platforms = [];
49+ source = {
50+ remotes = ["https://rubygems.org"];
51+ sha256 = "043lwdw2wsi6d55ifk0w3izi5l1d1h0alwyr3fixic7b94kc812n";
52+ type = "gem";
53+ };
54+ version = "0.1.3";
55+ };
56+ formatador = {
57+ groups = ["default"];
58+ platforms = [];
59+ source = {
60+ remotes = ["https://rubygems.org"];
61+ sha256 = "1gc26phrwlmlqrmz4bagq1wd5b7g64avpx0ghxr9xdxcvmlii0l0";
62+ type = "gem";
63+ };
64+ version = "0.2.5";
65+ };
66+ json = {
67+ groups = ["default"];
68+ platforms = [];
69+ source = {
70+ remotes = ["https://rubygems.org"];
71+ sha256 = "01v6jjpvh3gnq6sgllpfqahlgxzj50ailwhj9b3cd20hi2dx0vxp";
72+ type = "gem";
73+ };
74+ version = "2.1.0";
75+ };
276 mini_portile2 = {
77+ groups = ["default"];
78+ platforms = [];
379 source = {
480 remotes = ["https://rubygems.org"];
5− sha256 = "0gzfmcywp1da8nzfqsql2zqi648mfnx6qwkig3cv36n9m0yy676y";
81+ sha256 = "13d32jjadpjj6d2wdhkfpsmy68zjx90p49bgf8f7nkpz86r1fr11";
682 type = "gem";
783 };
884 version = "2.3.0";
985 };
1086 nokogiri = {
1187 dependencies = ["mini_portile2"];
12− source = {
13− remotes = ["https://rubygems.org"];
14− sha256 = "0byyxrazkfm29ypcx5q4syrv126nvjnf7z6bqi01sqkv4llsi4qz";
15− type = "gem";
16− };
88+ groups = ["default"];
89+ platforms = [];
90+ source = {
91+ remotes = ["https://rubygems.org"];
92+ sha256 = "0byyxrazkfm29ypcx5q4syrv126nvjnf7z6bqi01sqkv4llsi4qz";
93+ type = "gem";
94+ };
1795 version = "1.8.5";
1896 };
97+ ruby-libvirt = {
98+ groups = ["default"];
99+ platforms = [];
100+ source = {
101+ remotes = ["https://rubygems.org"];
102+ sha256 = "0d754d6pgdqyq52pl9hp0x38q1vn3vf9nz4nm5gqdj5i4fw7pba6";
103+ type = "gem";
104+ };
105+ version = "0.7.1";
106+ };
107+ vagrant-libvirt = {
108+ dependencies = ["fog-core" "fog-libvirt" "nokogiri"];
109+ groups = ["default"];
110+ platforms = [];
111+ source = {
112+ remotes = ["https://rubygems.org"];
113+ sha256 = "1wm5yvml3sxdzpnlp4q6yhy695syy8byd1g7cxll4pmj1kwlknym";
114+ type = "gem";
115+ };
116+ version = "0.0.45";
117+ };
19118}
pkgs/development/tools/vagrant/vagrant-libvirt.json.innew file+9
@@ -0,0 +1,9 @@
1+{
2+ "vagrant-libvirt": {
3+ "ruby_version":"@ruby_version@",
4+ "vagrant_version":"@vagrant_version@",
5+ "gem_version":"",
6+ "require":"",
7+ "sources":[]
8+ }
9+}