Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 166 lines 3.7 kB view raw
1{ lib 2, stdenv 3, fetchurl 4, pkg-config 5, autoreconfHook 6, makeWrapper 7, libxcrypt 8, ncurses 9, cpio 10, gperf 11, cdrkit 12, flex 13, bison 14, qemu 15, pcre2 16, augeas 17, libxml2 18, acl 19, libcap 20, libcap_ng 21, libconfig 22, systemd 23, fuse 24, yajl 25, libvirt 26, hivex 27, db 28, gmp 29, readline 30, file 31, numactl 32, libapparmor 33, jansson 34, getopt 35, perlPackages 36, ocamlPackages 37, libtirpc 38, appliance ? null 39, javaSupport ? false 40, jdk 41}: 42 43assert appliance == null || lib.isDerivation appliance; 44 45stdenv.mkDerivation rec { 46 pname = "libguestfs"; 47 version = "1.48.4"; 48 49 src = fetchurl { 50 url = "https://libguestfs.org/download/${lib.versions.majorMinor version}-stable/${pname}-${version}.tar.gz"; 51 sha256 = "sha256-ncIrbFpF8ZwsupEaN7Oo2G9idEUhsQ61PD05B+UIAxI="; 52 }; 53 54 strictDeps = true; 55 nativeBuildInputs = [ 56 autoreconfHook 57 bison 58 cdrkit 59 cpio 60 flex 61 getopt 62 gperf 63 makeWrapper 64 pkg-config 65 qemu 66 ] ++ (with perlPackages; [ perl libintl-perl GetoptLong ModuleBuild ]) 67 ++ (with ocamlPackages; [ ocaml findlib ]); 68 buildInputs = [ 69 libxcrypt 70 ncurses 71 jansson 72 pcre2 73 augeas 74 libxml2 75 acl 76 libcap 77 libcap_ng 78 libconfig 79 systemd 80 fuse 81 yajl 82 libvirt 83 gmp 84 readline 85 file 86 hivex 87 db 88 numactl 89 libapparmor 90 perlPackages.ModuleBuild 91 libtirpc 92 ] ++ (with ocamlPackages; [ ocamlbuild ocaml_libvirt gettext-stub ounit ]) 93 ++ lib.optional javaSupport jdk; 94 95 prePatch = '' 96 # build-time scripts 97 substituteInPlace run.in --replace '#!/bin/bash' '#!${stdenv.shell}' 98 substituteInPlace ocaml-link.sh.in --replace '#!/bin/bash' '#!${stdenv.shell}' 99 100 # $(OCAMLLIB) is read-only "${ocamlPackages.ocaml}/lib/ocaml" 101 substituteInPlace ocaml/Makefile.am --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml' 102 substituteInPlace ocaml/Makefile.in --replace '$(DESTDIR)$(OCAMLLIB)' '$(out)/lib/ocaml' 103 104 # some scripts hardcore /usr/bin/env which is not available in the build env 105 patchShebangs . 106 ''; 107 configureFlags = [ 108 "--disable-appliance" 109 "--disable-daemon" 110 "--with-distro=NixOS" 111 "--with-guestfs-path=${placeholder "out"}/lib/guestfs" 112 ] ++ lib.optionals (!javaSupport) [ "--without-java" ]; 113 patches = [ 114 ./libguestfs-syms.patch 115 ]; 116 117 createFindlibDestdir = true; 118 119 installFlags = [ "REALLY_INSTALL=yes" ]; 120 enableParallelBuilding = true; 121 122 postInstall = '' 123 mv "$out/lib/ocaml/guestfs" "$OCAMLFIND_DESTDIR/guestfs" 124 for bin in $out/bin/*; do 125 wrapProgram "$bin" \ 126 --prefix PATH : "$out/bin:${hivex}/bin:${qemu}/bin" \ 127 --prefix PERL5LIB : "$out/${perlPackages.perl.libPrefix}" 128 done 129 ''; 130 131 postFixup = lib.optionalString (appliance != null) '' 132 mkdir -p $out/{lib,lib64} 133 ln -s ${appliance} $out/lib64/guestfs 134 ln -s ${appliance} $out/lib/guestfs 135 ''; 136 137 doInstallCheck = appliance != null; 138 installCheckPhase = '' 139 runHook preInstallCheck 140 141 export HOME=$(mktemp -d) # avoid access to /homeless-shelter/.guestfish 142 143 ${qemu}/bin/qemu-img create -f qcow2 disk1.img 10G 144 145 $out/bin/guestfish <<'EOF' 146 add-drive disk1.img 147 run 148 list-filesystems 149 part-disk /dev/sda mbr 150 mkfs ext2 /dev/sda1 151 list-filesystems 152 EOF 153 154 runHook postInstallCheck 155 ''; 156 157 meta = with lib; { 158 description = "Tools for accessing and modifying virtual machine disk images"; 159 license = with licenses; [ gpl2Plus lgpl21Plus ]; 160 homepage = "https://libguestfs.org/"; 161 maintainers = with maintainers; [ offline ]; 162 platforms = platforms.linux; 163 # this is to avoid "output size exceeded" 164 hydraPlatforms = if appliance != null then appliance.meta.hydraPlatforms else platforms.linux; 165 }; 166}