1 { lib, stdenv, fetchurl, pkg-config, autoreconfHook, makeWrapper
2 , ncurses, cpio, gperf, cdrkit, flex, bison, qemu, pcre, augeas, libxml2
3 , acl, libcap, libcap_ng, libconfig, systemd, fuse, yajl, libvirt, hivex, db
4 , gmp, readline, file, numactl, libapparmor, jansson
5 , getopt, perlPackages, ocamlPackages
8 , javaSupport ? false, jdk ? null }:
10 assert appliance == null || lib.isDerivation appliance;
11 assert javaSupport -> jdk != null;
13 stdenv.mkDerivation rec {
18 url = "https://libguestfs.org/download/1.40-stable/${pname}-${version}.tar.gz";
19 sha256 = "ad6562c48c38e922a314cb45a90996843d81045595c4917f66b02a6c2dfe8058";
22 nativeBuildInputs = [ autoreconfHook makeWrapper pkg-config ];
24 ncurses cpio gperf jansson
25 cdrkit flex bison qemu pcre augeas libxml2 acl libcap libcap_ng libconfig
26 systemd fuse yajl libvirt gmp readline file hivex db
27 numactl libapparmor getopt perlPackages.ModuleBuild
29 ] ++ (with perlPackages; [ perl libintl_perl GetoptLong SysVirt ])
30 ++ (with ocamlPackages; [ ocaml findlib ocamlbuild ocaml_libvirt gettext-stub ounit ])
31 ++ lib.optional javaSupport jdk;
35 substituteInPlace run.in --replace '#!/bin/bash' '#!${stdenv.shell}'
36 substituteInPlace ocaml-link.sh --replace '#!/bin/bash' '#!${stdenv.shell}'
38 # $(OCAMLLIB) is read-only "${ocamlPackages.ocaml}/lib/ocaml"
39 substituteInPlace ocaml/Makefile.am --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
40 substituteInPlace ocaml/Makefile.in --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
41 substituteInPlace v2v/test-harness/Makefile.am --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
42 substituteInPlace v2v/test-harness/Makefile.in --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
44 # some scripts hardcore /usr/bin/env which is not available in the build env
47 configureFlags = [ "--disable-appliance" "--disable-daemon" "--with-distro=NixOS" ]
48 ++ lib.optionals (!javaSupport) [ "--disable-java" "--without-java" ];
49 patches = [ ./libguestfs-syms.patch ];
50 NIX_CFLAGS_COMPILE="-I${libxml2.dev}/include/libxml2/";
51 installFlags = [ "REALLY_INSTALL=yes" ];
52 enableParallelBuilding = true;
55 for bin in $out/bin/*; do
57 --prefix PATH : "$out/bin:${hivex}/bin:${qemu}/bin" \
58 --prefix PERL5LIB : "$out/${perlPackages.perl.libPrefix}"
62 postFixup = lib.optionalString (appliance != null) ''
63 mkdir -p $out/{lib,lib64}
64 ln -s ${appliance} $out/lib64/guestfs
65 ln -s ${appliance} $out/lib/guestfs
68 doInstallCheck = appliance != null;
69 installCheckPhase = ''
70 runHook preInstallCheck
72 export HOME=$(mktemp -d) # avoid access to /homeless-shelter/.guestfish
74 ${qemu}/bin/qemu-img create -f qcow2 disk1.img 10G
76 $out/bin/guestfish <<'EOF'
80 part-disk /dev/sda mbr
85 runHook postInstallCheck
89 description = "Tools for accessing and modifying virtual machine disk images";
90 license = with licenses; [ gpl2 lgpl21 ];
91 homepage = "https://libguestfs.org/";
92 maintainers = with maintainers; [offline];
93 platforms = platforms.linux;
94 # this is to avoid "output size exceeded"
95 hydraPlatforms = if appliance != null then appliance.meta.hydraPlatforms else platforms.linux;