2015-05-13 09:31:32 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2018-05-28 08:24:29 +01:00
|
|
|
cfg = config.virtualisation.vmware.guest;
|
2016-12-01 14:59:53 +00:00
|
|
|
open-vm-tools = if cfg.headless then pkgs.open-vm-tools-headless else pkgs.open-vm-tools;
|
2016-11-16 22:43:42 +00:00
|
|
|
xf86inputvmmouse = pkgs.xorg.xf86inputvmmouse;
|
2015-05-13 09:31:32 +01:00
|
|
|
in
|
|
|
|
{
|
2019-12-10 01:51:19 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "vmwareGuest" ] [ "virtualisation" "vmware" "guest" ])
|
|
|
|
];
|
|
|
|
|
2018-05-28 08:24:29 +01:00
|
|
|
options.virtualisation.vmware.guest = {
|
|
|
|
enable = mkEnableOption "VMWare Guest Support";
|
|
|
|
headless = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to disable X11-related features.";
|
2016-12-01 14:59:53 +00:00
|
|
|
};
|
2015-05-13 09:31:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
assertions = [ {
|
2021-11-21 01:50:41 +00:00
|
|
|
assertion = pkgs.stdenv.hostPlatform.isx86;
|
2018-08-20 20:11:29 +01:00
|
|
|
message = "VMWare guest is not currently supported on ${pkgs.stdenv.hostPlatform.system}";
|
2015-05-13 09:31:32 +01:00
|
|
|
} ];
|
|
|
|
|
2022-01-10 16:05:58 +00:00
|
|
|
boot.initrd.availableKernelModules = [ "mptspi" ];
|
2018-05-28 08:24:29 +01:00
|
|
|
boot.initrd.kernelModules = [ "vmw_pvscsi" ];
|
|
|
|
|
2015-05-13 09:31:32 +01:00
|
|
|
environment.systemPackages = [ open-vm-tools ];
|
|
|
|
|
|
|
|
systemd.services.vmware =
|
|
|
|
{ description = "VMWare Guest Service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2021-11-25 02:29:18 +00:00
|
|
|
after = [ "display-manager.service" ];
|
|
|
|
unitConfig.ConditionVirtualization = "vmware";
|
2015-05-13 09:31:32 +01:00
|
|
|
serviceConfig.ExecStart = "${open-vm-tools}/bin/vmtoolsd";
|
|
|
|
};
|
|
|
|
|
2021-09-19 16:15:41 +01:00
|
|
|
# Mount the vmblock for drag-and-drop and copy-and-paste.
|
2021-10-20 15:12:07 +01:00
|
|
|
systemd.mounts = mkIf (!cfg.headless) [
|
2021-09-19 16:15:41 +01:00
|
|
|
{
|
|
|
|
description = "VMware vmblock fuse mount";
|
|
|
|
documentation = [ "https://github.com/vmware/open-vm-tools/blob/master/open-vm-tools/vmblock-fuse/design.txt" ];
|
2021-11-25 02:29:18 +00:00
|
|
|
unitConfig.ConditionVirtualization = "vmware";
|
2021-09-19 16:15:41 +01:00
|
|
|
what = "${open-vm-tools}/bin/vmware-vmblock-fuse";
|
|
|
|
where = "/run/vmblock-fuse";
|
|
|
|
type = "fuse";
|
|
|
|
options = "subtype=vmware-vmblock,default_permissions,allow_other";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2021-10-20 15:12:07 +01:00
|
|
|
security.wrappers.vmware-user-suid-wrapper = mkIf (!cfg.headless) {
|
|
|
|
setuid = true;
|
2021-09-20 22:45:24 +01:00
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
source = "${open-vm-tools}/bin/vmware-user-suid-wrapper";
|
|
|
|
};
|
2021-09-19 16:15:41 +01:00
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
environment.etc.vmware-tools.source = "${open-vm-tools}/etc/vmware-tools/*";
|
2016-04-23 02:08:06 +01:00
|
|
|
|
2016-12-01 14:59:53 +00:00
|
|
|
services.xserver = mkIf (!cfg.headless) {
|
2015-05-13 09:31:32 +01:00
|
|
|
videoDrivers = mkOverride 50 [ "vmware" ];
|
2016-11-16 22:43:42 +00:00
|
|
|
modules = [ xf86inputvmmouse ];
|
2015-05-13 09:31:32 +01:00
|
|
|
|
|
|
|
config = ''
|
2016-11-16 22:43:42 +00:00
|
|
|
Section "InputClass"
|
2015-05-13 09:31:32 +01:00
|
|
|
Identifier "VMMouse"
|
2016-11-16 22:43:42 +00:00
|
|
|
MatchDevicePath "/dev/input/event*"
|
|
|
|
MatchProduct "ImPS/2 Generic Wheel Mouse"
|
2015-05-13 09:31:32 +01:00
|
|
|
Driver "vmmouse"
|
|
|
|
EndSection
|
|
|
|
'';
|
|
|
|
|
|
|
|
displayManager.sessionCommands = ''
|
|
|
|
${open-vm-tools}/bin/vmware-user-suid-wrapper
|
|
|
|
'';
|
|
|
|
};
|
2021-07-14 02:26:58 +01:00
|
|
|
|
|
|
|
services.udev.packages = [ open-vm-tools ];
|
2015-05-13 09:31:32 +01:00
|
|
|
};
|
|
|
|
}
|