1 { options, config, pkgs, lib, ... }:
5 opt = options.services.rkvm;
6 cfg = config.services.rkvm;
7 toml = pkgs.formats.toml { };
10 meta.maintainers = [ ];
12 options.services.rkvm = {
14 default = cfg.server.enable || cfg.client.enable;
15 defaultText = literalExpression "config.${opt.server.enable} || config.${opt.client.enable}";
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)";
28 type = types.submodule
30 freeformType = toml.type;
34 default = "0.0.0.0:5258";
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" ];
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";
57 This should be generated with {command}`rkvm-certificate-gen`.
64 default = "/etc/rkvm/key.pem";
69 This should be generated with {command}`rkvm-certificate-gen`.
77 Shared secret token to authenticate the client.
78 Make sure this matches your client's config.
85 description = "Structured server daemon configuration";
90 enable = mkEnableOption "the rkvm client daemon (input receiver)";
93 type = types.submodule
95 freeformType = toml.type;
99 example = "192.168.0.123:5258";
101 An RKVM server's internet socket address, either IPv4 or IPv6.
105 certificate = mkOption {
107 default = "/etc/rkvm/certificate.pem";
109 TLS ceritficate path.
112 This should be generated with {command}`rkvm-certificate-gen`.
117 password = mkOption {
120 Shared secret token to authenticate the client.
121 Make sure this matches your server's config.
128 description = "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}";
159 rkvm-server = mkIf cfg.server.enable (mkBase "server");
160 rkvm-client = mkIf cfg.client.enable (mkBase "client");