nixpkgs/nixos/modules/virtualisation/parallels-guest.nix

157 lines
4.4 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2014-11-11 00:32:05 +01:00
with lib;
let
prl-tools = config.hardware.parallels.package;
2014-11-11 00:32:05 +01:00
in
{
options = {
hardware.parallels = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
2015-09-15 08:01:02 +02:00
This enables Parallels Tools for Linux guests, along with provided
2014-11-11 00:32:05 +01:00
video, mouse and other hardware drivers.
'';
};
autoMountShares = mkOption {
type = types.bool;
default = true;
description = ''
Control prlfsmountd service. When this service is running, shares can not be manually
mounted through `mount -t prl_fs ...` as this service will remount and trample any set options.
Recommended to enable for simple file sharing, but extended share use such as for code should
disable this to manually mount shares.
'';
};
package = mkOption {
type = types.nullOr types.package;
default = config.boot.kernelPackages.prl-tools;
defaultText = "config.boot.kernelPackages.prl-tools";
example = literalExample "config.boot.kernelPackages.prl-tools";
description = ''
Defines which package to use for prl-tools. Override to change the version.
'';
};
2014-11-11 00:32:05 +01:00
};
};
config = mkIf config.hardware.parallels.enable {
services.xserver = {
drivers = singleton
nixos: Don't set LD_LIBRARY_PATH for graphics drivers that don't need it. A new internal option `hardware.opengl.setLdLibraryPath` is added which controls if `LD_LIBRARY_PATH` should be set to `/run/opengl-driver(-32)/lib`. It is false by default and is meant to be set to true by any driver which requires it. If this option is false, then `opengl.nix` and `xserver.nix` will not set `LD_LIBRARY_PATH`. Currently Mesa and NVidia drivers don't set `setLdLibraryPath` because they work with libglvnd and do not override libraries, while `amdgpu-pro`, `ati` and `parallels-guest` set it to true (the former two really need it, the last one doesn't build so is presumed to). Additionally, the `libPath` attribute within entries of `services.xserver.drivers` is removed. This made `xserver.nix` add the driver path directly to the `LD_LIBRARY_PATH` for the display manager (including X server). Not only is it redundant when the driver is added to `hardware.opengl.package` (assuming that `hardware.opengl.enable` is true), in fact all current drivers except `ati` set it incorrectly to the package path instead of package/lib. This removal of `LD_LIBRARY_PATH` could break certain packages using CUDA, but only those that themselves load `libcuda` or other NVidia driver libraries using `dlopen` (not if they just use `cudatoolkit`). A few have already been fixed but it is practically impossible to test all because most packages using CUDA are libraries/frameworks without a simple way to test. Fixes #11434 if only Mesa or NVidia graphics drivers are used.
2019-05-24 01:21:57 +02:00
{ name = "prlvideo"; modules = [ prl-tools ]; };
2014-11-11 00:32:05 +01:00
screenSection = ''
Option "NoMTRR"
'';
config = ''
Section "InputClass"
Identifier "prlmouse"
MatchIsPointer "on"
MatchTag "prlmouse"
Driver "prlmouse"
EndSection
'';
};
hardware.opengl.package = prl-tools;
hardware.opengl.package32 = pkgs.pkgsi686Linux.linuxPackages.prl-tools.override { libsOnly = true; kernel = null; };
nixos: Don't set LD_LIBRARY_PATH for graphics drivers that don't need it. A new internal option `hardware.opengl.setLdLibraryPath` is added which controls if `LD_LIBRARY_PATH` should be set to `/run/opengl-driver(-32)/lib`. It is false by default and is meant to be set to true by any driver which requires it. If this option is false, then `opengl.nix` and `xserver.nix` will not set `LD_LIBRARY_PATH`. Currently Mesa and NVidia drivers don't set `setLdLibraryPath` because they work with libglvnd and do not override libraries, while `amdgpu-pro`, `ati` and `parallels-guest` set it to true (the former two really need it, the last one doesn't build so is presumed to). Additionally, the `libPath` attribute within entries of `services.xserver.drivers` is removed. This made `xserver.nix` add the driver path directly to the `LD_LIBRARY_PATH` for the display manager (including X server). Not only is it redundant when the driver is added to `hardware.opengl.package` (assuming that `hardware.opengl.enable` is true), in fact all current drivers except `ati` set it incorrectly to the package path instead of package/lib. This removal of `LD_LIBRARY_PATH` could break certain packages using CUDA, but only those that themselves load `libcuda` or other NVidia driver libraries using `dlopen` (not if they just use `cudatoolkit`). A few have already been fixed but it is practically impossible to test all because most packages using CUDA are libraries/frameworks without a simple way to test. Fixes #11434 if only Mesa or NVidia graphics drivers are used.
2019-05-24 01:21:57 +02:00
hardware.opengl.setLdLibraryPath = true;
2014-11-11 00:32:05 +01:00
services.udev.packages = [ prl-tools ];
environment.systemPackages = [ prl-tools ];
boot.extraModulePackages = [ prl-tools ];
boot.kernelModules = [ "prl_tg" "prl_eth" "prl_fs" "prl_fs_freeze" ];
2014-11-11 00:32:05 +01:00
services.timesyncd.enable = false;
2014-11-11 00:32:05 +01:00
systemd.services.prltoolsd = {
description = "Parallels Tools' service";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${prl-tools}/bin/prltoolsd -f";
PIDFile = "/var/run/prltoolsd.pid";
};
};
systemd.services.prlfsmountd = mkIf config.hardware.parallels.autoMountShares {
2014-11-11 00:32:05 +01:00
description = "Parallels Shared Folders Daemon";
wantedBy = [ "multi-user.target" ];
serviceConfig = rec {
ExecStart = "${prl-tools}/sbin/prlfsmountd ${PIDFile}";
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /media";
ExecStopPost = "${prl-tools}/sbin/prlfsmountd -u";
PIDFile = "/run/prlfsmountd.pid";
};
};
systemd.services.prlshprint = {
description = "Parallels Shared Printer Tool";
wantedBy = [ "multi-user.target" ];
bindsTo = [ "cups.service" ];
2014-11-11 00:32:05 +01:00
serviceConfig = {
Type = "forking";
ExecStart = "${prl-tools}/bin/prlshprint";
};
};
systemd.user.services = {
prlcc = {
description = "Parallels Control Center";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${prl-tools}/bin/prlcc";
};
};
prldnd = {
description = "Parallels Control Center";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${prl-tools}/bin/prldnd";
};
};
prl_wmouse_d = {
description = "Parallels Walking Mouse Daemon";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${prl-tools}/bin/prl_wmouse_d";
};
};
prlcp = {
description = "Parallels CopyPaste Tool";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${prl-tools}/bin/prlcp";
};
};
prlsga = {
description = "Parallels Shared Guest Applications Tool";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${prl-tools}/bin/prlsga";
};
};
prlshprof = {
description = "Parallels Shared Profile Tool";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${prl-tools}/bin/prlshprof";
};
};
};
2014-11-11 00:32:05 +01:00
};
}