@@ -1,4 +1,4 @@
1−{ lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive, writeText }:
1+{ lib, fetchurl, buildRubyGem, bundlerEnv, ruby, libarchive, writeText, withLibvirt ? false, libvirt, pkgconfig }:
22
33let
44 # NOTE: bumping the version and updating the hash is insufficient;
@@ -15,7 +15,7 @@ let
1515 inherit ruby;
1616 gemfile = writeText "Gemfile" "";
1717 lockfile = writeText "Gemfile.lock" "";
18− gemset = lib.recursiveUpdate (import ./gemset.nix) {
18+ gemset = lib.recursiveUpdate (import ./gemset.nix) ({
1919 vagrant = {
2020 source = {
2121 type = "url";
@@ -23,7 +23,7 @@ let
2323 };
2424 inherit version;
2525 };
26− };
26+ } // lib.optionalAttrs withLibvirt (import ./gemset_libvirt.nix));
2727 };
2828
2929in buildRubyGem rec {
@@ -35,6 +35,8 @@ in buildRubyGem rec {
3535 dontBuild = false;
3636 src = fetchurl { inherit url sha256; };
3737
38+ buildInputs = lib.optional withLibvirt [ libvirt pkgconfig ];
39+
3840 patches = [
3941 ./unofficial-installation-nowarn.patch
4042 ./use-system-bundler-version.patch
@@ -45,7 +47,12 @@ in buildRubyGem rec {
4547 postInstall = ''
4648 wrapProgram "$out/bin/vagrant" \
4749 --set GEM_PATH "${deps}/lib/ruby/gems/${ruby.version.libDir}" \
48− --prefix PATH ':' "${lib.getBin libarchive}/bin"
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+ ''}
4956 '';
5057
5158 installCheckPhase = ''