1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 prl-tools = config.hardware.parallels.package;
7in
8
9{
10
11 options = {
12 hardware.parallels = {
13
14 enable = mkOption {
15 type = types.bool;
16 default = false;
17 description = ''
18 This enables Parallels Tools for Linux guests, along with provided
19 video, mouse and other hardware drivers.
20 '';
21 };
22
23 autoMountShares = mkOption {
24 type = types.bool;
25 default = true;
26 description = ''
27 Control prlfsmountd service. When this service is running, shares can not be manually
28 mounted through `mount -t prl_fs ...` as this service will remount and trample any set options.
29 Recommended to enable for simple file sharing, but extended share use such as for code should
30 disable this to manually mount shares.
31 '';
32 };
33
34 package = mkOption {
35 type = types.nullOr types.package;
36 default = config.boot.kernelPackages.prl-tools;
37 defaultText = "config.boot.kernelPackages.prl-tools";
38 example = literalExpression "config.boot.kernelPackages.prl-tools";
39 description = ''
40 Defines which package to use for prl-tools. Override to change the version.
41 '';
42 };
43 };
44
45 };
46
47 config = mkIf config.hardware.parallels.enable {
48
49 services.udev.packages = [ prl-tools ];
50
51 environment.systemPackages = [ prl-tools ];
52
53 boot.extraModulePackages = [ prl-tools ];
54
55 boot.kernelModules = [ "prl_fs" "prl_fs_freeze" "prl_tg" ]
56 ++ optional (pkgs.stdenv.hostPlatform.system == "aarch64-linux") "prl_notifier";
57
58 services.timesyncd.enable = false;
59
60 systemd.services.prltoolsd = {
61 description = "Parallels Tools Service";
62 wantedBy = [ "multi-user.target" ];
63 path = [ prl-tools ];
64 serviceConfig = {
65 ExecStart = "${prl-tools}/bin/prltoolsd -f";
66 PIDFile = "/var/run/prltoolsd.pid";
67 WorkingDirectory = "${prl-tools}/bin";
68 };
69 };
70
71 systemd.services.prlfsmountd = mkIf config.hardware.parallels.autoMountShares {
72 description = "Parallels Guest File System Sharing Tool";
73 wantedBy = [ "multi-user.target" ];
74 path = [ prl-tools ];
75 serviceConfig = rec {
76 ExecStart = "${prl-tools}/sbin/prlfsmountd ${PIDFile}";
77 ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /media";
78 ExecStopPost = "${prl-tools}/sbin/prlfsmountd -u";
79 PIDFile = "/run/prlfsmountd.pid";
80 WorkingDirectory = "${prl-tools}/bin";
81 };
82 };
83
84 systemd.services.prlshprint = {
85 description = "Parallels Printing Tool";
86 wantedBy = [ "multi-user.target" ];
87 bindsTo = [ "cups.service" ];
88 path = [ prl-tools ];
89 serviceConfig = {
90 ExecStart = "${prl-tools}/bin/prlshprint";
91 WorkingDirectory = "${prl-tools}/bin";
92 };
93 };
94
95 systemd.user.services = {
96 prlcc = {
97 description = "Parallels Control Center";
98 wantedBy = [ "graphical-session.target" ];
99 path = [ prl-tools ];
100 serviceConfig = {
101 ExecStart = "${prl-tools}/bin/prlcc";
102 WorkingDirectory = "${prl-tools}/bin";
103 };
104 };
105 prldnd = {
106 description = "Parallels Drag And Drop Tool";
107 wantedBy = [ "graphical-session.target" ];
108 path = [ prl-tools ];
109 serviceConfig = {
110 ExecStart = "${prl-tools}/bin/prldnd";
111 WorkingDirectory = "${prl-tools}/bin";
112 };
113 };
114 prlcp = {
115 description = "Parallels Copy Paste Tool";
116 wantedBy = [ "graphical-session.target" ];
117 path = [ prl-tools ];
118 serviceConfig = {
119 ExecStart = "${prl-tools}/bin/prlcp";
120 Restart = "always";
121 WorkingDirectory = "${prl-tools}/bin";
122 };
123 };
124 prlsga = {
125 description = "Parallels Shared Guest Applications Tool";
126 wantedBy = [ "graphical-session.target" ];
127 path = [ prl-tools ];
128 serviceConfig = {
129 ExecStart = "${prl-tools}/bin/prlsga";
130 WorkingDirectory = "${prl-tools}/bin";
131 };
132 };
133 prlshprof = {
134 description = "Parallels Shared Profile Tool";
135 wantedBy = [ "graphical-session.target" ];
136 path = [ prl-tools ];
137 serviceConfig = {
138 ExecStart = "${prl-tools}/bin/prlshprof";
139 WorkingDirectory = "${prl-tools}/bin";
140 };
141 };
142 };
143
144 };
145}