46 assert appliance == null || lib.isDerivation appliance;
48 stdenv.mkDerivation (finalAttrs: {
54 url = "https://libguestfs.org/download/${lib.versions.majorMinor finalAttrs.version}-stable/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
55 sha256 = "sha256-tK+g+P1YAgXqVUjUaLxuQ8O+y5leL2DmMmVSemMFQkY=";
74 ++ (with perlPackages; [
80 ++ (with ocamlPackages; [
106 perlPackages.ModuleBuild
109 ocamlPackages.ocamlbuild
110 ocamlPackages.ocaml_libvirt
113 ocamlPackages.ocamlbuild
114 ] ++ lib.optional javaSupport jdk;
121 "--enable-install-daemon"
122 "--disable-appliance"
123 "--with-distro=NixOS"
125 "CPPFLAGS=-I${lib.getDev libxml2}/include/libxml2"
126 "INSTALL_OCAMLLIB=${placeholder "out"}/lib/ocaml"
127 "--with-guestfs-path=${placeholder "out"}/lib/guestfs"
128 ] ++ lib.optionals (!javaSupport) [ "--without-java" ];
131 ./libguestfs-syms.patch
132 # Fixes PERL Sys-Guestfs build failure
133 ./Revert-perl-Pass-CFLAGS-through-extra_linker_flags.patch
136 createFindlibDestdir = true;
138 installFlags = [ "REALLY_INSTALL=yes" ];
139 enableParallelBuilding = true;
147 # move guestfsd (the component running in the appliance) to a separate output
148 mkdir -p $guestfsd/bin
149 mv $out/sbin/guestfsd $guestfsd/bin/guestfsd
150 remove-references-to -t $out $guestfsd/bin/guestfsd
152 mv "$out/lib/ocaml/guestfs" "$OCAMLFIND_DESTDIR/guestfs"
153 for bin in $out/bin/*; do
155 --prefix PATH : "$out/bin:${hivex}/bin:${qemu}/bin" \
156 --prefix PERL5LIB : "$out/${perlPackages.perl.libPrefix}"
160 postFixup = lib.optionalString (appliance != null) ''
161 mkdir -p $out/{lib,lib64}
162 ln -s ${appliance} $out/lib64/guestfs
163 ln -s ${appliance} $out/lib/guestfs
166 doInstallCheck = appliance != null;
167 installCheckPhase = ''
168 runHook preInstallCheck
170 export HOME=$(mktemp -d) # avoid access to /homeless-shelter/.guestfish
172 ${qemu}/bin/qemu-img create -f qcow2 disk1.img 10G
174 $out/bin/guestfish <<'EOF'
178 part-disk /dev/sda mbr
183 runHook postInstallCheck
187 description = "Tools for accessing and modifying virtual machine disk images";
188 license = with lib.licenses; [
192 homepage = "https://libguestfs.org/";
193 maintainers = with lib.maintainers; [
197 platforms = lib.platforms.linux;
198 # this is to avoid "output size exceeded"
199 hydraPlatforms = if appliance != null then appliance.meta.hydraPlatforms else lib.platforms.linux;