nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 testers,
5 fetchurl,
6 pkg-config,
7 makeWrapper,
8 autoreconfHook,
9 bash-completion,
10 OVMF,
11 qemu,
12 ocamlPackages,
13 perl,
14 cpio,
15 getopt,
16 libosinfo,
17 pcre2,
18 libxml2,
19 json_c,
20 glib,
21 libguestfs-with-appliance,
22 cdrkit,
23 nbdkit,
24 withWindowsGuestSupport ? true,
25 pkgsCross, # for rsrvany
26 virtio-win,
27 gitUpdater,
28}:
29
30stdenv.mkDerivation (finalAttrs: {
31 pname = "virt-v2v";
32 version = "2.8.1";
33
34 src = fetchurl {
35 url = "https://download.libguestfs.org/virt-v2v/${lib.versions.majorMinor finalAttrs.version}-stable/virt-v2v-${finalAttrs.version}.tar.gz";
36 sha256 = "sha256-RJPwtI6GHN+W+Pw8jdEAgQMbR42aGqTYW2rPtAYBPYM=";
37 };
38
39 postPatch = ''
40 # TODO: allow guest != host CPU ISA
41 substituteInPlace output/output_qemu.ml \
42 --replace-fail '/usr/share/OVMF' ""${OVMF.fd}/FV/" \
43 --replace-fail '/usr/share/AAVMF' ""${OVMF.fd}/FV/"
44
45 patchShebangs .
46 '';
47
48 nativeBuildInputs = [
49 pkg-config
50 autoreconfHook
51 makeWrapper
52 bash-completion
53 perl
54 libguestfs-with-appliance
55 qemu
56 cpio
57 cdrkit
58 getopt
59 ]
60 ++ (with ocamlPackages; [
61 ocaml
62 findlib
63 ]);
64
65 buildInputs = [
66 json_c
67 libosinfo
68 pcre2
69 libxml2
70 glib
71 ]
72 ++ (with ocamlPackages; [
73 ocaml_libvirt
74 nbd
75 ]);
76
77 postInstall = ''
78 for bin in $out/bin/*; do
79 wrapProgram "$bin" \
80 --prefix PATH : "$out/bin:${
81 lib.makeBinPath [
82 nbdkit
83 ocamlPackages.nbd
84 qemu
85 ]
86 }"
87 done
88 ''
89 + lib.optionalString withWindowsGuestSupport ''
90 ln -s "${virtio-win}" $out/share/virtio-win
91 ln -s "${pkgsCross.mingwW64.rhsrvany}/bin/" $out/share/virt-tools
92 '';
93
94 env.PKG_CONFIG_BASH_COMPLETION_COMPLETIONSDIR = "${placeholder "out"}/share/bash-completion/completions";
95
96 passthru.tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
97
98 passthru.updateScript = gitUpdater {
99 url = "https://github.com/libguestfs/guestfs-tools";
100 rev-prefix = "v";
101 odd-unstable = true;
102 };
103
104 meta = {
105 homepage = "https://github.com/libguestfs/virt-v2v";
106 description = "Convert guests from foreign hypervisors to run on KVM";
107 license = lib.licenses.gpl2Only;
108 maintainers = with lib.maintainers; [ lukts30 ];
109 platforms = lib.platforms.linux;
110 mainProgram = "virt-v2v";
111 };
112})