diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2018-12-19 12:18:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-19 12:18:44 +0100 |
commit | da093022a43c305a1c15fe645d36f3ba29b57db3 (patch) | |
tree | a303f2646941579c60ed7498c5ef305f7bb1e31a /pkgs | |
parent | 857853d5f10c81663dbc5844f0074efb903361a0 (diff) | |
parent | c660f3d41964fb8da83d1938a58edf8801e0af0d (diff) | |
download | nixpkgs-da093022a43c305a1c15fe645d36f3ba29b57db3.tar nixpkgs-da093022a43c305a1c15fe645d36f3ba29b57db3.tar.gz nixpkgs-da093022a43c305a1c15fe645d36f3ba29b57db3.tar.bz2 nixpkgs-da093022a43c305a1c15fe645d36f3ba29b57db3.tar.lz nixpkgs-da093022a43c305a1c15fe645d36f3ba29b57db3.tar.xz nixpkgs-da093022a43c305a1c15fe645d36f3ba29b57db3.tar.zst nixpkgs-da093022a43c305a1c15fe645d36f3ba29b57db3.zip |
Merge pull request #52413 from mat8913/vagrant-libvirt
vagrant: build and install vagrant-libvirt plugin
Diffstat (limited to 'pkgs')
5 files changed, 236 insertions, 16 deletions
diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix index 3671605a407..7fdf5c83901 100644 --- a/pkgs/development/ruby-modules/gem-config/default.nix +++ b/pkgs/development/ruby-modules/gem-config/default.nix @@ -23,7 +23,7 @@ , cmake, libssh2, openssl, mysql, darwin, git, perl, pcre, gecode_3, curl , msgpack, qt59, libsodium, snappy, libossp_uuid, lxc, libpcap, xorg, gtk2, buildRubyGem , cairo, re2, rake, gobject-introspection, gdk_pixbuf, zeromq, graphicsmagick, libcxx, file -, libselinux ? null, libsepol ? null +, libselinux ? null, libsepol ? null, libvirt }@args: let @@ -314,6 +314,14 @@ in buildInputs = [ imagemagick which ]; }; + ruby-libvirt = attrs: { + buildInputs = [ libvirt pkgconfig ]; + buildFlags = [ + "--with-libvirt-include=${libvirt}/include" + "--with-libvirt-lib=${libvirt}/lib" + ]; + }; + ruby-lxc = attrs: { buildInputs = [ lxc ]; }; diff --git a/pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch b/pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch new file mode 100644 index 00000000000..f87ff5135b3 --- /dev/null +++ b/pkgs/development/tools/vagrant/0004-Support-system-installed-plugins.patch @@ -0,0 +1,97 @@ +From: Antonio Terceiro <terceiro@debian.org> +Date: Wed, 27 May 2015 09:36:17 -0300 +Subject: Support system-installed plugins +Source: https://salsa.debian.org/ruby-team/vagrant/blob/cb672c6dc0c63f6552c5ec4d6d7d22929d353503/debian/patches/0004-Support-system-installed-plugins.patch + +Plugins must be installed as regular Ruby libraries, and they must +contain /usr/share/vagrant-plugins/plugins.d/$PLUGINNAME.json with the +following content: + +{ + "${PLUGINNAME}": { + "ruby_version":"$(ruby -e 'puts RUBY_VERSION')", + "vagrant_version":"$(cat /usr/share/vagrant/version.txt)", + "gem_version":"", + "require":"", + "sources":[] + } +} +--- + lib/vagrant/plugin/manager.rb | 4 ++-- + lib/vagrant/plugin/state_file.rb | 22 +++++++++++++++++++++- + 2 files changed, 23 insertions(+), 3 deletions(-) + +diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb +index 567347d..d9d76a0 100644 +--- a/lib/vagrant/plugin/manager.rb ++++ b/lib/vagrant/plugin/manager.rb +@@ -18,7 +18,7 @@ module Vagrant + + # Returns the path to the [StateFile] for system plugins. + def self.system_plugins_file +- dir = Vagrant.installer_embedded_dir ++ dir = '@system_plugin_dir@' + return nil if !dir + Pathname.new(dir).join("plugins.json") + end +@@ -38,7 +38,7 @@ module Vagrant + + system_path = self.class.system_plugins_file + @system_file = nil +- @system_file = StateFile.new(system_path) if system_path && system_path.file? ++ @system_file = StateFile.new(system_path, true) if system_path && system_path.file? + + @local_file = nil + @globalized = @localized = false +diff --git a/lib/vagrant/plugin/state_file.rb b/lib/vagrant/plugin/state_file.rb +index c6872d4..935d431 100644 +--- a/lib/vagrant/plugin/state_file.rb ++++ b/lib/vagrant/plugin/state_file.rb +@@ -11,8 +11,9 @@ module Vagrant + # @return [Pathname] path to file + attr_reader :path + +- def initialize(path) ++ def initialize(path, system = false) + @path = path ++ @system = system + + @data = {} + if @path.exist? +@@ -28,6 +29,21 @@ module Vagrant + + @data["version"] ||= "1" + @data["installed"] ||= {} ++ load_extra_plugins ++ end ++ ++ def load_extra_plugins ++ extra_plugins = Dir.glob(@path.dirname.join('plugins.d', '*.json')) ++ extra_plugins.each do |filename| ++ json = File.read(filename) ++ begin ++ plugin_data = JSON.parse(json) ++ @data["installed"].merge!(plugin_data) ++ rescue JSON::ParserError => e ++ raise Vagrant::Errors::PluginStateFileParseError, ++ path: filename, message: e.message ++ end ++ end + end + + # Add a plugin that is installed to the state file. +@@ -107,6 +123,14 @@ module Vagrant + f.close + FileUtils.mv(f.path, @path) + end ++ rescue Errno::EACCES ++ # Ignore permission denied against system-installed plugins; regular ++ # users are not supposed to write there. ++ raise unless @system ++ rescue Errno::EROFS ++ # Ignore read-only filesystem against system-installed plugins; regular ++ # users are not supposed to write there. ++ raise unless @system + end + + protected diff --git a/pkgs/development/tools/vagrant/default.nix b/pkgs/development/tools/vagrant/default.nix index 74992560f3f..f2e6b00c09b 100644 --- a/pkgs/development/tools/vagrant/default.nix +++ b/pkgs/development/tools/vagrant/default.nix @@ -1,4 +1,4 @@ -{ lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive, writeText, withLibvirt ? true, libvirt, pkgconfig }: +{ lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive, writeText, withLibvirt ? true}: let # NOTE: bumping the version and updating the hash is insufficient; @@ -35,24 +35,31 @@ in buildRubyGem rec { dontBuild = false; src = fetchurl { inherit url sha256; }; - buildInputs = lib.optional withLibvirt [ libvirt pkgconfig ]; - patches = [ ./unofficial-installation-nowarn.patch ./use-system-bundler-version.patch + ./0004-Support-system-installed-plugins.patch ]; + postPatch = '' + substituteInPlace lib/vagrant/plugin/manager.rb --subst-var-by \ + system_plugin_dir "$out/vagrant-plugins" + ''; + # PATH additions: # - libarchive: Make `bsdtar` available for extracting downloaded boxes postInstall = '' wrapProgram "$out/bin/vagrant" \ --set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}" \ - --prefix PATH ':' "${lib.getBin libarchive}/bin" \ - ${lib.optionalString withLibvirt '' - --prefix PATH ':' "${pkgconfig}/bin" \ - --prefix PKG_CONFIG_PATH ':' \ - "${lib.makeSearchPath "lib/pkgconfig" [ libvirt ]}" - ''} + --prefix PATH ':' "${lib.getBin libarchive}/bin" + + mkdir -p "$out/vagrant-plugins/plugins.d" + echo '{}' > "$out/vagrant-plugins/plugins.json" + '' + + lib.optionalString withLibvirt '' + substitute ${./vagrant-libvirt.json.in} $out/vagrant-plugins/plugins.d/vagrant-libvirt.json \ + --subst-var-by ruby_version ${ruby.version} \ + --subst-var-by vagrant_version ${version} ''; installCheckPhase = '' diff --git a/pkgs/development/tools/vagrant/gemset_libvirt.nix b/pkgs/development/tools/vagrant/gemset_libvirt.nix index aeaf42341a8..2631833dc00 100644 --- a/pkgs/development/tools/vagrant/gemset_libvirt.nix +++ b/pkgs/development/tools/vagrant/gemset_libvirt.nix @@ -1,19 +1,118 @@ { + excon = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "15l9w0938c19nxmrp09n75qpmm64k12xj69h47yvxzcxcpbgnkb2"; + type = "gem"; + }; + version = "0.62.0"; + }; + fog-core = { + dependencies = ["builder" "excon" "formatador"]; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "0ac25s2wv7m6av7h7vjzd2bg3srhnn5yrz3lq1xpimhnfmp82sw6"; + type = "gem"; + }; + version = "1.43.0"; + }; + fog-json = { + dependencies = ["fog-core" "multi_json"]; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1zj8llzc119zafbmfa4ai3z5s7c4vp9akfs0f9l2piyvcarmlkyx"; + type = "gem"; + }; + version = "1.2.0"; + }; + fog-libvirt = { + dependencies = ["fog-core" "fog-json" "fog-xml" "json" "ruby-libvirt"]; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "0gk16gsjd51x71wla7h5jqr6x5ywpwz5l8jdv76f9mr6fp1j2bkf"; + type = "gem"; + }; + version = "0.5.0"; + }; + fog-xml = { + dependencies = ["fog-core" "nokogiri"]; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "043lwdw2wsi6d55ifk0w3izi5l1d1h0alwyr3fixic7b94kc812n"; + type = "gem"; + }; + version = "0.1.3"; + }; + formatador = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1gc26phrwlmlqrmz4bagq1wd5b7g64avpx0ghxr9xdxcvmlii0l0"; + type = "gem"; + }; + version = "0.2.5"; + }; + json = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "01v6jjpvh3gnq6sgllpfqahlgxzj50ailwhj9b3cd20hi2dx0vxp"; + type = "gem"; + }; + version = "2.1.0"; + }; mini_portile2 = { + groups = ["default"]; + platforms = []; source = { remotes = ["https://rubygems.org"]; - sha256 = "0gzfmcywp1da8nzfqsql2zqi648mfnx6qwkig3cv36n9m0yy676y"; + sha256 = "13d32jjadpjj6d2wdhkfpsmy68zjx90p49bgf8f7nkpz86r1fr11"; type = "gem"; }; version = "2.3.0"; }; nokogiri = { dependencies = ["mini_portile2"]; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "0byyxrazkfm29ypcx5q4syrv126nvjnf7z6bqi01sqkv4llsi4qz"; - type = "gem"; - }; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "0byyxrazkfm29ypcx5q4syrv126nvjnf7z6bqi01sqkv4llsi4qz"; + type = "gem"; + }; version = "1.8.5"; }; + ruby-libvirt = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "0d754d6pgdqyq52pl9hp0x38q1vn3vf9nz4nm5gqdj5i4fw7pba6"; + type = "gem"; + }; + version = "0.7.1"; + }; + vagrant-libvirt = { + dependencies = ["fog-core" "fog-libvirt" "nokogiri"]; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "1wm5yvml3sxdzpnlp4q6yhy695syy8byd1g7cxll4pmj1kwlknym"; + type = "gem"; + }; + version = "0.0.45"; + }; } diff --git a/pkgs/development/tools/vagrant/vagrant-libvirt.json.in b/pkgs/development/tools/vagrant/vagrant-libvirt.json.in new file mode 100644 index 00000000000..22060e1c2db --- /dev/null +++ b/pkgs/development/tools/vagrant/vagrant-libvirt.json.in @@ -0,0 +1,9 @@ +{ + "vagrant-libvirt": { + "ruby_version":"@ruby_version@", + "vagrant_version":"@vagrant_version@", + "gem_version":"", + "require":"", + "sources":[] + } +} |