1 { config, lib, pkgs, ... }:
6 cfg = config.virtualisation.vmware.guest;
7 open-vm-tools = if cfg.headless then pkgs.open-vm-tools-headless else pkgs.open-vm-tools;
8 xf86inputvmmouse = pkgs.xorg.xf86inputvmmouse;
12 (mkRenamedOptionModule [ "services" "vmwareGuest" ] [ "virtualisation" "vmware" "guest" ])
15 options.virtualisation.vmware.guest = {
16 enable = mkEnableOption (lib.mdDoc "VMWare Guest Support");
19 default = !config.services.xserver.enable;
20 defaultText = "!config.services.xserver.enable";
21 description = lib.mdDoc "Whether to disable X11-related features.";
25 config = mkIf cfg.enable {
27 assertion = pkgs.stdenv.hostPlatform.isx86 || pkgs.stdenv.hostPlatform.isAarch64;
28 message = "VMWare guest is not currently supported on ${pkgs.stdenv.hostPlatform.system}";
31 boot.initrd.availableKernelModules = [ "mptspi" ];
32 boot.initrd.kernelModules = lib.optionals pkgs.stdenv.hostPlatform.isx86 [ "vmw_pvscsi" ];
34 environment.systemPackages = [ open-vm-tools ];
36 systemd.services.vmware =
37 { description = "VMWare Guest Service";
38 wantedBy = [ "multi-user.target" ];
39 after = [ "display-manager.service" ];
40 unitConfig.ConditionVirtualization = "vmware";
41 serviceConfig.ExecStart = "${open-vm-tools}/bin/vmtoolsd";
44 # Mount the vmblock for drag-and-drop and copy-and-paste.
45 systemd.mounts = mkIf (!cfg.headless) [
47 description = "VMware vmblock fuse mount";
48 documentation = [ "https://github.com/vmware/open-vm-tools/blob/master/open-vm-tools/vmblock-fuse/design.txt" ];
49 unitConfig.ConditionVirtualization = "vmware";
50 what = "${open-vm-tools}/bin/vmware-vmblock-fuse";
51 where = "/run/vmblock-fuse";
53 options = "subtype=vmware-vmblock,default_permissions,allow_other";
54 wantedBy = [ "multi-user.target" ];
58 security.wrappers.vmware-user-suid-wrapper = mkIf (!cfg.headless) {
62 source = "${open-vm-tools}/bin/vmware-user-suid-wrapper";
65 environment.etc.vmware-tools.source = "${open-vm-tools}/etc/vmware-tools/*";
67 services.xserver = mkIf (!cfg.headless) {
68 modules = [ xf86inputvmmouse ];
73 MatchDevicePath "/dev/input/event*"
74 MatchProduct "ImPS/2 Generic Wheel Mouse"
79 displayManager.sessionCommands = ''
80 ${open-vm-tools}/bin/vmware-user-suid-wrapper
84 services.udev.packages = [ open-vm-tools ];