Unverified Commit 398c52b9 authored by Felix Bargfeldt's avatar Felix Bargfeldt Committed by GitHub
Browse files

vmware-workstation: allow overriding, update meta attrs, refactor (#395985)

parents ea131632 5e3aa011
Loading
Loading
Loading
Loading
+53 −60
Original line number Diff line number Diff line
@@ -33,28 +33,44 @@
  unzip,
}:

let
  # base - versions
stdenv.mkDerivation (finalAttrs: {
  pname = "vmware-workstation";
  version = "17.6.3";
  build = "24583834";

  # macOS - versions
  unlockerVersion = "3.0.5";

  # macOS - Unlocker
  unlockerSrc = fetchFromGitHub {
    owner = "paolo-projects";
    repo = "unlocker";
    rev = "${unlockerVersion}";
    sha256 = "sha256-JSEW1gqQuLGRkathlwZU/TnG6dL/xWKW4//SfE+kO0A=";
  src = requireFile {
    name = "VMware-Workstation-Full-${finalAttrs.version}-${finalAttrs.build}.x86_64.bundle";
    url = "https://support.broadcom.com/group/ecx/productdownloads?subfamily=VMware%20Workstation%20Pro&freeDownloads=true";
    hash = "sha256-eVdZF3KN7UxtC4n0q2qBvpp3PADuto0dEqwNsSVHjuA=";
  };

  vmware-unpack-env = buildFHSEnv {
    pname = "vmware-unpack-env";
    inherit version;
    inherit (finalAttrs) version;
    targetPkgs = pkgs: [ zlib ];
  };

  unpackPhase = ''
    ${finalAttrs.vmware-unpack-env}/bin/vmware-unpack-env -c "sh ${finalAttrs.src} --extract unpacked"
  '';

  macOSUnlockerSrc = fetchFromGitHub {
    owner = "paolo-projects";
    repo = "unlocker";
    tag = "3.0.5";
    hash = "sha256-JSEW1gqQuLGRkathlwZU/TnG6dL/xWKW4//SfE+kO0A=";
  };

  postPatch = lib.optionalString enableMacOSGuests ''
    cp -R "${finalAttrs.macOSUnlockerSrc}" unlocker/

    substituteInPlace unlocker/unlocker.py --replace \
      "/usr/lib/vmware/bin/" "$out/lib/vmware/bin"

    substituteInPlace unlocker/unlocker.py --replace \
      "/usr/lib/vmware/lib/libvmwarebase.so/libvmwarebase.so" "$out/lib/vmware/lib/libvmwarebase.so/libvmwarebase.so"
  '';

  readline70_compat63 = symlinkJoin {
    name = "readline70_compat63";
    paths = [ readline70 ];
@@ -62,10 +78,20 @@ let
      ln -s $out/lib/libreadline.so $out/lib/libreadline.so.6
    '';
  };
in
stdenv.mkDerivation rec {
  pname = "vmware-workstation";
  inherit version build;

  nativeBuildInputs =
    [
      python3
      finalAttrs.vmware-unpack-env
      autoPatchelfHook
      makeWrapper
    ]
    ++ lib.optionals enableInstaller [
      bzip2
      sqlite
      finalAttrs.readline70_compat63
    ]
    ++ lib.optionals enableMacOSGuests [ unzip ];

  buildInputs = [
    libxslt
@@ -99,40 +125,6 @@ stdenv.mkDerivation rec {
    xorg.libXtst
  ];

  nativeBuildInputs =
    [
      python3
      vmware-unpack-env
      autoPatchelfHook
      makeWrapper
    ]
    ++ lib.optionals enableInstaller [
      bzip2
      sqlite
      readline70_compat63
    ]
    ++ lib.optionals enableMacOSGuests [ unzip ];

  src = requireFile {
    name = "VMware-Workstation-Full-${version}-${build}.x86_64.bundle";
    url = "https://support.broadcom.com/group/ecx/productdownloads?subfamily=VMware%20Workstation%20Pro&freeDownloads=true";
    hash = "sha256-eVdZF3KN7UxtC4n0q2qBvpp3PADuto0dEqwNsSVHjuA=";
  };

  unpackPhase = ''
    ${vmware-unpack-env}/bin/vmware-unpack-env -c "sh ${src} --extract unpacked"
  '';

  postPatch = lib.optionalString enableMacOSGuests ''
    cp -R "${unlockerSrc}" unlocker/

    substituteInPlace unlocker/unlocker.py --replace \
      "/usr/lib/vmware/bin/" "$out/lib/vmware/bin"

    substituteInPlace unlocker/unlocker.py --replace \
      "/usr/lib/vmware/lib/libvmwarebase.so/libvmwarebase.so" "$out/lib/vmware/lib/libvmwarebase.so/libvmwarebase.so"
  '';

  installPhase = ''
    runHook preInstall

@@ -167,7 +159,7 @@ stdenv.mkDerivation rec {
      cp ${./vmware-installer-bootstrap} $out/etc/vmware-installer/bootstrap
      sed -i -e "s,@@INSTALLERDIR@@,$dest," $out/etc/vmware-installer/bootstrap
      sed -i -e "s,@@IVERSION@@,$vmware_installer_version," $out/etc/vmware-installer/bootstrap
      sed -i -e "s,@@BUILD@@,${build}," $out/etc/vmware-installer/bootstrap
      sed -i -e "s,@@BUILD@@,${finalAttrs.build}," $out/etc/vmware-installer/bootstrap

      # create database of vmware guest tools (avoids vmware fetching them later)
      mkdir -p $out/etc/vmware-installer/components
@@ -181,7 +173,7 @@ stdenv.mkDerivation rec {
        component_version=$(cat unpacked/$component/manifest.xml | grep -oPm1 "(?<=<version>)[^<]+")
        component_core_id=$([ "$component" == "vmware-installer" ] && echo "-1" || echo "1")
        type=$([ "$component" == "vmware-workstation" ] && echo "0" || echo "1")
        sqlite3 "$database_filename" "INSERT INTO components(name,version,buildNumber,component_core_id,longName,description,type) VALUES('$component','$component_version',${build},$component_core_id,'$component','$component',$type);"
        sqlite3 "$database_filename" "INSERT INTO components(name,version,buildNumber,component_core_id,longName,description,type) VALUES('$component','$component_version',${finalAttrs.build},$component_core_id,'$component','$component',$type);"
        mkdir -p $out/etc/vmware-installer/components/$component
        cp -r $folder/* $out/etc/vmware-installer/components/$component
      done
@@ -195,8 +187,8 @@ stdenv.mkDerivation rec {
    ## VMware Config
    echo "Installing VMware Config"
    cp ${./vmware-config} $out/etc/vmware/config
    sed -i -e "s,@@VERSION@@,${version}," $out/etc/vmware/config
    sed -i -e "s,@@BUILD@@,${build}," $out/etc/vmware/config
    sed -i -e "s,@@VERSION@@,${finalAttrs.version}," $out/etc/vmware/config
    sed -i -e "s,@@BUILD@@,${finalAttrs.build}," $out/etc/vmware/config
    sed -i -e "s,@@PREFIXDIR@@,$out," $out/etc/vmware/config

    ## VMware VMX
@@ -378,16 +370,17 @@ stdenv.mkDerivation rec {
    runHook postInstall
  '';

  meta = with lib; {
  meta = {
    description = "Industry standard desktop hypervisor for x86-64 architecture";
    homepage = "https://www.vmware.com/products/workstation-pro.html";
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    homepage = "https://www.vmware.com/products/desktop-hypervisor/workstation-and-fusion";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = lib.licenses.unfree;
    platforms = [ "x86_64-linux" ];
    maintainers = with maintainers; [
    mainProgram = "vmware";
    maintainers = with lib.maintainers; [
      cawilliamson
      deinferno
      vifino
    ];
  };
}
})