tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/rkvm: init
Co-authored-by: Lin Jian <me@linj.tech>
ckie
2 years ago
f3ad4def
177e36be
+165
2 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
misc
rkvm.nix
+1
nixos/modules/module-list.nix
···
706
706
./services/misc/ripple-data-api.nix
707
707
./services/misc/rippled.nix
708
708
./services/misc/rmfakecloud.nix
709
709
+
./services/misc/rkvm.nix
709
710
./services/misc/rshim.nix
710
711
./services/misc/safeeyes.nix
711
712
./services/misc/sdrplay.nix
+164
nixos/modules/services/misc/rkvm.nix
···
1
1
+
{ options, config, pkgs, lib, ... }:
2
2
+
3
3
+
with lib;
4
4
+
let
5
5
+
opt = options.services.rkvm;
6
6
+
cfg = config.services.rkvm;
7
7
+
toml = pkgs.formats.toml { };
8
8
+
in
9
9
+
{
10
10
+
meta.maintainers = with maintainers; [ ckie ];
11
11
+
12
12
+
options.services.rkvm = {
13
13
+
enable = mkOption {
14
14
+
default = cfg.server.enable || cfg.client.enable;
15
15
+
defaultText = literalExpression "config.${opt.server.enable} || config.${opt.client.enable}";
16
16
+
type = types.bool;
17
17
+
description = mdDoc ''
18
18
+
Whether to enable rkvm, a Virtual KVM switch for Linux machines.
19
19
+
'';
20
20
+
};
21
21
+
22
22
+
package = mkPackageOption pkgs "rkvm" { };
23
23
+
24
24
+
server = {
25
25
+
enable = mkEnableOption "the rkvm server daemon (input transmitter)";
26
26
+
27
27
+
settings = mkOption {
28
28
+
type = types.submodule
29
29
+
{
30
30
+
freeformType = toml.type;
31
31
+
options = {
32
32
+
listen = mkOption {
33
33
+
type = types.str;
34
34
+
default = "0.0.0.0:5258";
35
35
+
description = mdDoc ''
36
36
+
An internet socket address to listen on, either IPv4 or IPv6.
37
37
+
'';
38
38
+
};
39
39
+
40
40
+
switch-keys = mkOption {
41
41
+
type = types.listOf types.str;
42
42
+
default = [ "left-alt" "left-ctrl" ];
43
43
+
description = mdDoc ''
44
44
+
A key list specifying a host switch combination.
45
45
+
46
46
+
_A list of key names is available in <https://github.com/htrefil/rkvm/blob/master/switch-keys.md>._
47
47
+
'';
48
48
+
};
49
49
+
50
50
+
certificate = mkOption {
51
51
+
type = types.path;
52
52
+
default = "/etc/rkvm/certificate.pem";
53
53
+
description = mdDoc ''
54
54
+
TLS certificate path.
55
55
+
56
56
+
::: {.note}
57
57
+
This should be generated with {command}`rkvm-certificate-gen`.
58
58
+
:::
59
59
+
'';
60
60
+
};
61
61
+
62
62
+
key = mkOption {
63
63
+
type = types.path;
64
64
+
default = "/etc/rkvm/key.pem";
65
65
+
description = mdDoc ''
66
66
+
TLS key path.
67
67
+
68
68
+
::: {.note}
69
69
+
This should be generated with {command}`rkvm-certificate-gen`.
70
70
+
:::
71
71
+
'';
72
72
+
};
73
73
+
74
74
+
password = mkOption {
75
75
+
type = types.str;
76
76
+
description = mdDoc ''
77
77
+
Shared secret token to authenticate the client.
78
78
+
Make sure this matches your client's config.
79
79
+
'';
80
80
+
};
81
81
+
};
82
82
+
};
83
83
+
84
84
+
default = { };
85
85
+
description = mdDoc "Structured server daemon configuration";
86
86
+
};
87
87
+
};
88
88
+
89
89
+
client = {
90
90
+
enable = mkEnableOption "the rkvm client daemon (input receiver)";
91
91
+
92
92
+
settings = mkOption {
93
93
+
type = types.submodule
94
94
+
{
95
95
+
freeformType = toml.type;
96
96
+
options = {
97
97
+
server = mkOption {
98
98
+
type = types.str;
99
99
+
example = "192.168.0.123:5258";
100
100
+
description = mdDoc ''
101
101
+
An RKVM server's internet socket address, either IPv4 or IPv6.
102
102
+
'';
103
103
+
};
104
104
+
105
105
+
certificate = mkOption {
106
106
+
type = types.path;
107
107
+
default = "/etc/rkvm/certificate.pem";
108
108
+
description = mdDoc ''
109
109
+
TLS ceritficate path.
110
110
+
111
111
+
::: {.note}
112
112
+
This should be generated with {command}`rkvm-certificate-gen`.
113
113
+
:::
114
114
+
'';
115
115
+
};
116
116
+
117
117
+
password = mkOption {
118
118
+
type = types.str;
119
119
+
description = mdDoc ''
120
120
+
Shared secret token to authenticate the client.
121
121
+
Make sure this matches your server's config.
122
122
+
'';
123
123
+
};
124
124
+
};
125
125
+
};
126
126
+
127
127
+
default = {};
128
128
+
description = mdDoc "Structured client daemon configuration";
129
129
+
};
130
130
+
};
131
131
+
132
132
+
};
133
133
+
134
134
+
config = mkIf cfg.enable {
135
135
+
environment.systemPackages = [ cfg.package ];
136
136
+
137
137
+
systemd.services =
138
138
+
let
139
139
+
mkBase = component: {
140
140
+
description = "RKVM ${component}";
141
141
+
wantedBy = [ "multi-user.target" ];
142
142
+
after = {
143
143
+
server = [ "network.target" ];
144
144
+
client = [ "network-online.target" ];
145
145
+
}.${component};
146
146
+
wants = {
147
147
+
server = [ ];
148
148
+
client = [ "network-online.target" ];
149
149
+
}.${component};
150
150
+
serviceConfig = {
151
151
+
ExecStart = "${cfg.package}/bin/rkvm-${component} ${toml.generate "rkvm-${component}.toml" cfg.${component}.settings}";
152
152
+
Restart = "always";
153
153
+
RestartSec = 5;
154
154
+
Type = "simple";
155
155
+
};
156
156
+
};
157
157
+
in
158
158
+
{
159
159
+
rkvm-server = mkIf cfg.server.enable (mkBase "server");
160
160
+
rkvm-client = mkIf cfg.client.enable (mkBase "client");
161
161
+
};
162
162
+
};
163
163
+
164
164
+
}