···
1
+
{ options, config, pkgs, lib, ... }:
5
+
opt = options.services.rkvm;
6
+
cfg = config.services.rkvm;
7
+
toml = pkgs.formats.toml { };
10
+
meta.maintainers = with maintainers; [ ckie ];
12
+
options.services.rkvm = {
14
+
default = cfg.server.enable || cfg.client.enable;
15
+
defaultText = literalExpression "config.${opt.server.enable} || config.${opt.client.enable}";
17
+
description = mdDoc ''
18
+
Whether to enable rkvm, a Virtual KVM switch for Linux machines.
22
+
package = mkPackageOption pkgs "rkvm" { };
25
+
enable = mkEnableOption "the rkvm server daemon (input transmitter)";
27
+
settings = mkOption {
28
+
type = types.submodule
30
+
freeformType = toml.type;
34
+
default = "0.0.0.0:5258";
35
+
description = mdDoc ''
36
+
An internet socket address to listen on, either IPv4 or IPv6.
40
+
switch-keys = mkOption {
41
+
type = types.listOf types.str;
42
+
default = [ "left-alt" "left-ctrl" ];
43
+
description = mdDoc ''
44
+
A key list specifying a host switch combination.
46
+
_A list of key names is available in <https://github.com/htrefil/rkvm/blob/master/switch-keys.md>._
50
+
certificate = mkOption {
52
+
default = "/etc/rkvm/certificate.pem";
53
+
description = mdDoc ''
54
+
TLS certificate path.
57
+
This should be generated with {command}`rkvm-certificate-gen`.
64
+
default = "/etc/rkvm/key.pem";
65
+
description = mdDoc ''
69
+
This should be generated with {command}`rkvm-certificate-gen`.
74
+
password = mkOption {
76
+
description = mdDoc ''
77
+
Shared secret token to authenticate the client.
78
+
Make sure this matches your client's config.
85
+
description = mdDoc "Structured server daemon configuration";
90
+
enable = mkEnableOption "the rkvm client daemon (input receiver)";
92
+
settings = mkOption {
93
+
type = types.submodule
95
+
freeformType = toml.type;
99
+
example = "192.168.0.123:5258";
100
+
description = mdDoc ''
101
+
An RKVM server's internet socket address, either IPv4 or IPv6.
105
+
certificate = mkOption {
107
+
default = "/etc/rkvm/certificate.pem";
108
+
description = mdDoc ''
109
+
TLS ceritficate path.
112
+
This should be generated with {command}`rkvm-certificate-gen`.
117
+
password = mkOption {
119
+
description = mdDoc ''
120
+
Shared secret token to authenticate the client.
121
+
Make sure this matches your server's config.
128
+
description = mdDoc "Structured client daemon configuration";
134
+
config = mkIf cfg.enable {
135
+
environment.systemPackages = [ cfg.package ];
139
+
mkBase = component: {
140
+
description = "RKVM ${component}";
141
+
wantedBy = [ "multi-user.target" ];
143
+
server = [ "network.target" ];
144
+
client = [ "network-online.target" ];
148
+
client = [ "network-online.target" ];
151
+
ExecStart = "${cfg.package}/bin/rkvm-${component} ${toml.generate "rkvm-${component}.toml" cfg.${component}.settings}";
152
+
Restart = "always";
159
+
rkvm-server = mkIf cfg.server.enable (mkBase "server");
160
+
rkvm-client = mkIf cfg.client.enable (mkBase "client");