stockholm/tv/3modules/x0vncserver.nix

48 lines
1.3 KiB
Nix
Raw Normal View History

2017-08-02 00:13:21 +00:00
with import <stockholm/lib>;
{ 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 {
2021-12-25 10:41:06 +00:00
krebs.systemd.services.x0vncserver = {};
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);
};
}