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

This commit is contained in:
Felix Bargfeldt 2025-05-21 14:34:15 +02:00 committed by GitHub
commit 398c52b9d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,28 +33,44 @@
unzip, unzip,
}: }:
let stdenv.mkDerivation (finalAttrs: {
# base - versions pname = "vmware-workstation";
version = "17.6.3"; version = "17.6.3";
build = "24583834"; build = "24583834";
# macOS - versions src = requireFile {
unlockerVersion = "3.0.5"; 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";
# macOS - Unlocker hash = "sha256-eVdZF3KN7UxtC4n0q2qBvpp3PADuto0dEqwNsSVHjuA=";
unlockerSrc = fetchFromGitHub {
owner = "paolo-projects";
repo = "unlocker";
rev = "${unlockerVersion}";
sha256 = "sha256-JSEW1gqQuLGRkathlwZU/TnG6dL/xWKW4//SfE+kO0A=";
}; };
vmware-unpack-env = buildFHSEnv { vmware-unpack-env = buildFHSEnv {
pname = "vmware-unpack-env"; pname = "vmware-unpack-env";
inherit version; inherit (finalAttrs) version;
targetPkgs = pkgs: [ zlib ]; 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 { readline70_compat63 = symlinkJoin {
name = "readline70_compat63"; name = "readline70_compat63";
paths = [ readline70 ]; paths = [ readline70 ];
@ -62,10 +78,20 @@ let
ln -s $out/lib/libreadline.so $out/lib/libreadline.so.6 ln -s $out/lib/libreadline.so $out/lib/libreadline.so.6
''; '';
}; };
in
stdenv.mkDerivation rec { nativeBuildInputs =
pname = "vmware-workstation"; [
inherit version build; python3
finalAttrs.vmware-unpack-env
autoPatchelfHook
makeWrapper
]
++ lib.optionals enableInstaller [
bzip2
sqlite
finalAttrs.readline70_compat63
]
++ lib.optionals enableMacOSGuests [ unzip ];
buildInputs = [ buildInputs = [
libxslt libxslt
@ -99,40 +125,6 @@ stdenv.mkDerivation rec {
xorg.libXtst 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 = '' installPhase = ''
runHook preInstall runHook preInstall
@ -167,7 +159,7 @@ stdenv.mkDerivation rec {
cp ${./vmware-installer-bootstrap} $out/etc/vmware-installer/bootstrap cp ${./vmware-installer-bootstrap} $out/etc/vmware-installer/bootstrap
sed -i -e "s,@@INSTALLERDIR@@,$dest," $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,@@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) # create database of vmware guest tools (avoids vmware fetching them later)
mkdir -p $out/etc/vmware-installer/components 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_version=$(cat unpacked/$component/manifest.xml | grep -oPm1 "(?<=<version>)[^<]+")
component_core_id=$([ "$component" == "vmware-installer" ] && echo "-1" || echo "1") component_core_id=$([ "$component" == "vmware-installer" ] && echo "-1" || echo "1")
type=$([ "$component" == "vmware-workstation" ] && echo "0" || 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 mkdir -p $out/etc/vmware-installer/components/$component
cp -r $folder/* $out/etc/vmware-installer/components/$component cp -r $folder/* $out/etc/vmware-installer/components/$component
done done
@ -195,8 +187,8 @@ stdenv.mkDerivation rec {
## VMware Config ## VMware Config
echo "Installing VMware Config" echo "Installing VMware Config"
cp ${./vmware-config} $out/etc/vmware/config cp ${./vmware-config} $out/etc/vmware/config
sed -i -e "s,@@VERSION@@,${version}," $out/etc/vmware/config sed -i -e "s,@@VERSION@@,${finalAttrs.version}," $out/etc/vmware/config
sed -i -e "s,@@BUILD@@,${build}," $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 sed -i -e "s,@@PREFIXDIR@@,$out," $out/etc/vmware/config
## VMware VMX ## VMware VMX
@ -378,16 +370,17 @@ stdenv.mkDerivation rec {
runHook postInstall runHook postInstall
''; '';
meta = with lib; { meta = {
description = "Industry standard desktop hypervisor for x86-64 architecture"; description = "Industry standard desktop hypervisor for x86-64 architecture";
homepage = "https://www.vmware.com/products/workstation-pro.html"; homepage = "https://www.vmware.com/products/desktop-hypervisor/workstation-and-fusion";
sourceProvenance = with sourceTypes; [ binaryNativeCode ]; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = licenses.unfree; license = lib.licenses.unfree;
platforms = [ "x86_64-linux" ]; platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ mainProgram = "vmware";
maintainers = with lib.maintainers; [
cawilliamson cawilliamson
deinferno deinferno
vifino vifino
]; ];
}; };
} })