btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / gu / guestfs-tools / package.nix
blobfb790543b1a9583af12d7778dd2c5fe1aff65b08
2   lib,
3   stdenv,
4   fetchurl,
5   bash-completion,
6   bison,
7   cdrkit,
8   cpio,
9   curl,
10   flex,
11   getopt,
12   glib,
13   gnupg,
14   hivex,
15   jansson,
16   libguestfs-with-appliance,
17   libosinfo,
18   libvirt,
19   libxml2,
20   makeWrapper,
21   ncurses,
22   ocamlPackages,
23   openssl,
24   pcre2,
25   perlPackages,
26   pkg-config,
27   qemu,
28   xz,
29   gitUpdater,
32 stdenv.mkDerivation (finalAttrs: {
33   pname = "guestfs-tools";
34   version = "1.52.2";
36   src = fetchurl {
37     url = "https://download.libguestfs.org/guestfs-tools/${lib.versions.majorMinor finalAttrs.version}-stable/guestfs-tools-${finalAttrs.version}.tar.gz";
38     hash = "sha256-02khDS2NLG1QOSqswtDoqBX2Mg6sE/OiUoP9JFs4vTU=";
39   };
41   nativeBuildInputs =
42     [
43       bison
44       cdrkit
45       cpio
46       flex
47       getopt
48       makeWrapper
49       pkg-config
50       qemu
51     ]
52     ++ (with perlPackages; [
53       GetoptLong
54       libintl-perl
55       ModuleBuild
56       perl
57       Po4a
58     ])
59     ++ (with ocamlPackages; [
60       findlib
61       ocaml
62       ounit2
63     ]);
65   buildInputs = [
66     bash-completion
67     glib
68     hivex
69     jansson
70     libguestfs-with-appliance
71     libosinfo
72     libvirt
73     libxml2
74     ncurses
75     openssl
76     pcre2
77     xz
78   ];
80   postPatch = ''
81     # If it uses the executable name, then there's nothing we can do
82     # when wrapping to stop it looking in
83     # $out/etc/.virt-builder-wrapped, which won't exist.
84     substituteInPlace common/mlstdutils/std_utils.ml \
85         --replace Sys.executable_name '(Array.get Sys.argv 0)'
86   '';
88   preConfigure = ''
89     patchShebangs ocaml-dep.sh.in ocaml-link.sh.in run.in
90   '';
92   makeFlags = [
93     "LIBGUESTFS_PATH=${libguestfs-with-appliance}/lib/guestfs"
94   ];
96   installFlags = [
97     "BASH_COMPLETIONS_DIR=${placeholder "out"}/share/bash-completion/completions"
98   ];
100   enableParallelBuilding = true;
102   postInstall = ''
103     wrapProgram $out/bin/virt-builder \
104       --argv0 virt-builder \
105       --prefix PATH : ${
106         lib.makeBinPath [
107           curl
108           gnupg
109         ]
110       }:$out/bin \
111       --suffix VIRT_BUILDER_DIRS : /etc:$out/etc
112     wrapProgram $out/bin/virt-win-reg \
113       --prefix PERL5LIB : ${
114         with perlPackages;
115         makeFullPerlPath [
116           hivex
117           libintl-perl
118           libguestfs-with-appliance
119         ]
120       }
121   '';
123   passthru.updateScript = gitUpdater {
124     url = "https://github.com/libguestfs/guestfs-tools";
125     rev-prefix = "v";
126     odd-unstable = true;
127   };
129   meta = {
130     description = "Extra tools for accessing and modifying virtual machine disk images";
131     license = with lib.licenses; [
132       gpl2Plus
133       lgpl21Plus
134     ];
135     homepage = "https://libguestfs.org/";
136     changelog = "https://www.libguestfs.org/guestfs-tools-release-notes-${lib.versions.majorMinor finalAttrs.version}.1.html";
137     maintainers = [ ];
138     platforms = lib.platforms.linux;
139     hydraPlatforms = [ ];
140   };