2022-12-09 00:31:56 +00:00
|
|
|
with import ./lib;
|
2017-08-02 00:13:21 +00:00
|
|
|
{ config, pkgs, ... }: let
|
|
|
|
cfg = config.tv.x0vncserver;
|
|
|
|
in {
|
|
|
|
options.tv.x0vncserver = {
|
|
|
|
display = mkOption {
|
|
|
|
default = ":${toString config.services.xserver.display}";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
enable = mkEnableOption "tv.x0vncserver";
|
|
|
|
pwfile = mkOption {
|
2021-12-25 10:41:06 +00:00
|
|
|
default = toString <secrets> + "/vncpasswd";
|
2017-08-02 00:13:21 +00:00
|
|
|
description = ''
|
|
|
|
Use vncpasswd to edit pwfile.
|
|
|
|
See: nix-shell -p tigervnc --run 'man vncpasswd'
|
|
|
|
'';
|
2021-12-25 10:41:06 +00:00
|
|
|
type = types.absolute-pathname;
|
2017-08-02 00:13:21 +00:00
|
|
|
};
|
|
|
|
rfbport = mkOption {
|
|
|
|
default = 5900;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
user = mkOption {
|
|
|
|
default = config.krebs.build.user;
|
|
|
|
type = types.user;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
2022-12-29 12:44:45 +00:00
|
|
|
krebs.systemd.services.x0vncserver.restartIfCredentialsChange = true;
|
2017-08-02 00:13:21 +00:00
|
|
|
systemd.services.x0vncserver = {
|
2021-12-25 10:41:06 +00:00
|
|
|
after = [ "graphical.target" ];
|
|
|
|
requires = [ "graphical.target" ];
|
2017-08-02 00:13:21 +00:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.tigervnc}/bin/x0vncserver ${toString [
|
|
|
|
"-display ${cfg.display}"
|
2021-12-25 10:41:06 +00:00
|
|
|
"-passwordfile \${CREDENTIALS_DIRECTORY}/pwfile"
|
2017-08-02 00:13:21 +00:00
|
|
|
"-rfbport ${toString cfg.rfbport}"
|
|
|
|
]}";
|
2021-12-25 10:41:06 +00:00
|
|
|
LoadCredential = "ssh_key:${cfg.pwfile}";
|
2017-08-02 00:13:21 +00:00
|
|
|
User = cfg.user.name;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
tv.iptables.input-retiolum-accept-tcp = singleton (toString cfg.rfbport);
|
|
|
|
};
|
|
|
|
}
|