nixpkgs/pkgs/development/libraries/libguestfs/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

169 lines
3.6 KiB
Nix
Raw Normal View History

2022-08-03 08:48:00 +00:00
{ lib
, stdenv
, fetchurl
, pkg-config
, autoreconfHook
, makeWrapper
2022-09-29 15:13:49 +00:00
, libxcrypt
2022-08-03 08:48:00 +00:00
, ncurses
, cpio
, gperf
, cdrkit
, flex
, bison
, qemu
, pcre2
, augeas
, libxml2
, acl
, libcap
, libcap_ng
, libconfig
, systemd
, fuse
, yajl
, libvirt
, hivex
, db
, gmp
, readline
, file
, numactl
, libapparmor
, jansson
, getopt
, perlPackages
, ocamlPackages
2020-08-21 12:55:40 +00:00
, libtirpc
, appliance ? null
2022-08-03 08:48:00 +00:00
, javaSupport ? false
, jdk
, zstd
2022-08-03 08:48:00 +00:00
}:
assert appliance == null || lib.isDerivation appliance;
stdenv.mkDerivation rec {
pname = "libguestfs";
version = "1.50.1";
src = fetchurl {
2021-08-27 12:00:59 +00:00
url = "https://libguestfs.org/download/${lib.versions.majorMinor version}-stable/${pname}-${version}.tar.gz";
sha256 = "sha256-Xmhx6I+C5SHjHUQt5qELZJcCN8t5VumdEXsSO1hWWm8=";
};
strictDeps = true;
nativeBuildInputs = [
2022-08-03 08:48:00 +00:00
autoreconfHook
bison
cdrkit
cpio
flex
getopt
gperf
makeWrapper
pkg-config
qemu
zstd
] ++ (with perlPackages; [ perl libintl-perl GetoptLong ModuleBuild ])
2022-08-03 08:48:00 +00:00
++ (with ocamlPackages; [ ocaml findlib ]);
buildInputs = [
2022-09-29 15:13:49 +00:00
libxcrypt
2022-08-03 08:48:00 +00:00
ncurses
jansson
pcre2
augeas
libxml2
acl
libcap
libcap_ng
libconfig
systemd
fuse
yajl
libvirt
gmp
readline
file
hivex
db
numactl
libapparmor
perlPackages.ModuleBuild
2020-08-21 12:55:40 +00:00
libtirpc
] ++ (with ocamlPackages; [ ocamlbuild ocaml_libvirt gettext-stub ounit ])
2022-08-03 08:48:00 +00:00
++ lib.optional javaSupport jdk;
2017-02-22 06:01:09 +00:00
prePatch = ''
# build-time scripts
substituteInPlace run.in --replace '#!/bin/bash' '#!${stdenv.shell}'
2021-08-27 12:00:59 +00:00
substituteInPlace ocaml-link.sh.in --replace '#!/bin/bash' '#!${stdenv.shell}'
2017-02-22 06:01:09 +00:00
# $(OCAMLLIB) is read-only "${ocamlPackages.ocaml}/lib/ocaml"
substituteInPlace ocaml/Makefile.am --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
substituteInPlace ocaml/Makefile.in --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml'
2017-05-19 11:29:29 +00:00
# some scripts hardcore /usr/bin/env which is not available in the build env
patchShebangs .
2017-02-22 06:01:09 +00:00
'';
2021-08-27 12:00:59 +00:00
configureFlags = [
"--disable-appliance"
"--disable-daemon"
"--with-distro=NixOS"
"--with-guestfs-path=${placeholder "out"}/lib/guestfs"
] ++ lib.optionals (!javaSupport) [ "--without-java" ];
patches = [
./libguestfs-syms.patch
];
createFindlibDestdir = true;
2019-11-05 01:10:31 +00:00
installFlags = [ "REALLY_INSTALL=yes" ];
2017-05-19 11:29:29 +00:00
enableParallelBuilding = true;
postInstall = ''
mv "$out/lib/ocaml/guestfs" "$OCAMLFIND_DESTDIR/guestfs"
for bin in $out/bin/*; do
wrapProgram "$bin" \
2018-03-21 13:05:34 +00:00
--prefix PATH : "$out/bin:${hivex}/bin:${qemu}/bin" \
--prefix PERL5LIB : "$out/${perlPackages.perl.libPrefix}"
done
'';
postFixup = lib.optionalString (appliance != null) ''
2018-03-21 13:05:34 +00:00
mkdir -p $out/{lib,lib64}
ln -s ${appliance} $out/lib64/guestfs
ln -s ${appliance} $out/lib/guestfs
'';
doInstallCheck = appliance != null;
2018-03-21 13:05:34 +00:00
installCheckPhase = ''
runHook preInstallCheck
2018-03-21 13:05:34 +00:00
export HOME=$(mktemp -d) # avoid access to /homeless-shelter/.guestfish
${qemu}/bin/qemu-img create -f qcow2 disk1.img 10G
$out/bin/guestfish <<'EOF'
add-drive disk1.img
run
list-filesystems
part-disk /dev/sda mbr
mkfs ext2 /dev/sda1
list-filesystems
EOF
runHook postInstallCheck
'';
meta = with lib; {
description = "Tools for accessing and modifying virtual machine disk images";
license = with licenses; [ gpl2Plus lgpl21Plus ];
homepage = "https://libguestfs.org/";
2022-08-03 08:48:00 +00:00
maintainers = with maintainers; [ offline ];
platforms = platforms.linux;
# this is to avoid "output size exceeded"
hydraPlatforms = if appliance != null then appliance.meta.hydraPlatforms else platforms.linux;
};
}