Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at netboot-syslinux-multiplatform 153 lines 5.3 kB view raw
1{ lib, stdenv, fetchurl, system ? builtins.currentSystem, ovftoolBundles ? {} 2, requireFile, autoPatchelfHook, makeWrapper, unzip 3, glibc, c-ares, libxcrypt-legacy, expat, icu60, xercesc, zlib 4}: 5 6let 7 version = "4.5.0-20459872"; 8 9 ovftoolZipUnpackPhase = '' 10 runHook preUnpack 11 unzip ${ovftoolSource} 12 extracted=ovftool/ 13 if [ -d "$extracted" ]; then 14 echo "ovftool extracted successfully" >&2 15 else 16 echo "Could not find $extracted - are you sure this is ovftool?" >&2 17 exit 1 18 fi 19 runHook postUnpack 20 ''; 21 22 ovftoolSystems = let 23 baseUrl = "https://vdc-download.vmware.com/vmwb-repository/dcr-public"; 24 in { 25 "i686-linux" = rec { 26 filename = "VMware-ovftool-${version}-lin.i386.zip"; 27 url = "${baseUrl}/b70b2ad5-861a-4c11-b081-e541586bf934/57109c63-6b80-4ced-95f2-1b7255200a36/${filename}"; 28 sha256 = "11zs5dm4gmssm94s501p66l4s8v9p7prrd87cfa903mwmyp0ihnx"; 29 unpackPhase = ovftoolZipUnpackPhase; 30 }; 31 "x86_64-linux" = rec { 32 filename = "VMware-ovftool-${version}-lin.x86_64.zip"; 33 url = "${baseUrl}/f87355ff-f7a9-4532-b312-0be218a92eac/b2916af6-9f4f-4112-adac-49d1d6c81f63/${filename}"; 34 sha256 = "1fkm18yfkkm92m7ccl6b4nxy5lagwwldq56b567091a5sgad38zw"; 35 unpackPhase = ovftoolZipUnpackPhase; 36 }; 37 }; 38 39 ovftoolSystem = if builtins.hasAttr system ovftoolSystems then 40 ovftoolSystems.${system} 41 else throw "System '${system}' is unsupported by ovftool"; 42 43 ovftoolSource = if builtins.hasAttr system ovftoolBundles then 44 ovftoolBundles.${system} 45 else 46 fetchurl { 47 name = ovftoolSystem.filename; 48 url = ovftoolSystem.url; 49 sha256 = ovftoolSystem.sha256; 50 }; 51in 52stdenv.mkDerivation rec { 53 pname = "ovftool"; 54 inherit version; 55 56 src = ovftoolSource; 57 58 # Maintainers: try downloading a NixOS OVA and run the following to test: 59 # `./result/bin/ovftool https://channels.nixos.org/nixos-unstable/latest-nixos-x86_64-linux.ova nixos.ovf` 60 # Some dependencies are not loaded until operations actually occur! 61 buildInputs = [ 62 glibc 63 libxcrypt-legacy 64 c-ares 65 expat 66 icu60 67 xercesc 68 zlib 69 ]; 70 71 nativeBuildInputs = [ autoPatchelfHook makeWrapper unzip ]; 72 73 preferLocalBuild = true; 74 75 sourceRoot = "."; 76 77 unpackPhase = ovftoolSystem.unpackPhase; 78 79 # Expects a directory named 'ovftool' containing the ovftool install. 80 # Based on https://aur.archlinux.org/packages/vmware-ovftool/ 81 # with the addition of a libexec directory and a Nix-style binary wrapper. 82 installPhase = '' 83 runHook preInstall 84 if [ -d ovftool ]; then 85 # Ensure we're in the staging directory 86 cd ovftool 87 fi 88 # libraries 89 install -m 755 -d "$out/lib/${pname}" 90 # These all appear to be VMWare proprietary except for libgoogleurl and libcurl. 91 # The rest of the libraries that the installer extracts are omitted here, 92 # and provided in buildInputs. Since libcurl depends on VMWare's OpenSSL, 93 # we have to use both here too. 94 # 95 # FIXME: can we replace libgoogleurl? Possibly from Chromium? 96 # FIXME: tell VMware to use a modern version of OpenSSL. 97 # 98 install -m 644 -t "$out/lib/${pname}" \ 99 libgoogleurl.so.59 \ 100 libssoclient.so \ 101 libvim-types.so libvmacore.so libvmomi.so \ 102 libcurl.so.4 libcrypto.so.1.0.2 libssl.so.1.0.2 103 # libexec binaries 104 install -m 755 -d "$out/libexec/${pname}" 105 install -m 755 -t "$out/libexec/${pname}" ovftool.bin 106 install -m 644 -t "$out/libexec/${pname}" icudt44l.dat 107 # libexec resources 108 for subdir in "certs" "env" "env/en" "schemas/DMTF" "schemas/vmware"; do 109 install -m 755 -d "$out/libexec/${pname}/$subdir" 110 install -m 644 -t "$out/libexec/${pname}/$subdir" "$subdir"/*.* 111 done 112 # EULA/OSS files 113 install -m 755 -d "$out/share/licenses/${pname}" 114 install -m 644 -t "$out/share/licenses/${pname}" \ 115 "vmware.eula" "vmware-eula.rtf" "open_source_licenses.txt" 116 # documentation files 117 install -m 755 -d "$out/share/doc/${pname}" 118 install -m 644 -t "$out/share/doc/${pname}" "README.txt" 119 # binary wrapper; note that LC_CTYPE is defaulted to en_US.UTF-8 by 120 # VMWare's wrapper script. We use C.UTF-8 instead. 121 install -m 755 -d "$out/bin" 122 makeWrapper "$out/libexec/${pname}/ovftool.bin" "$out/bin/ovftool" \ 123 --set-default LC_CTYPE C.UTF-8 \ 124 --prefix LD_LIBRARY_PATH : "$out/lib" 125 runHook postInstall 126 ''; 127 128 preFixup = '' 129 addAutoPatchelfSearchPath "$out/lib" 130 ''; 131 132 doInstallCheck = true; 133 134 installCheckPhase = '' 135 # This is a NixOS 22.11 image (doesn't actually matter) with a 1 MiB root disk that's all zero. 136 # Make sure that it converts properly. 137 mkdir -p ovftool-check 138 cd ovftool-check 139 140 $out/bin/ovftool ${./installCheckPhase.ova} nixos.ovf 141 if [ ! -f nixos.ovf ] || [ ! -f nixos.mf ] || [ ! -f nixos-disk1.vmdk ]; then 142 exit 1 143 fi 144 ''; 145 146 meta = with lib; { 147 description = "VMWare tools for working with OVF, OVA, and VMX images"; 148 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 149 license = licenses.unfree; 150 maintainers = with maintainers; [ numinit wolfangaukang ]; 151 platforms = builtins.attrNames ovftoolSystems; 152 }; 153}