1# This module implements a terminal service based on ‘x11vnc’. It
2# listens on port 5900 for VNC connections. It then presents a login
3# screen to the user. If the user successfully authenticates, x11vnc
4# checks to see if a X server is already running for that user. If
5# not, a X server (Xvfb) is started for that user. The Xvfb instances
6# persist across VNC sessions.
7
8{ lib, pkgs, ... }:
9
10with lib;
11
12{
13
14 config = {
15
16 services.xserver.enable = true;
17 services.xserver.videoDrivers = [];
18
19 # Enable GDM. Any display manager will do as long as it supports XDMCP.
20 services.xserver.displayManager.gdm.enable = true;
21
22 systemd.sockets.terminal-server =
23 { description = "Terminal Server Socket";
24 wantedBy = [ "sockets.target" ];
25 before = [ "multi-user.target" ];
26 socketConfig.Accept = true;
27 socketConfig.ListenStream = 5900;
28 };
29
30 systemd.services."terminal-server@" =
31 { description = "Terminal Server";
32
33 path =
34 [ pkgs.xorg.xorgserver.out pkgs.gawk pkgs.which pkgs.openssl pkgs.xorg.xauth
35 pkgs.nettools pkgs.shadow pkgs.procps pkgs.utillinux pkgs.bash
36 ];
37
38 environment.FD_GEOM = "1024x786x24";
39 environment.FD_XDMCP_IF = "127.0.0.1";
40 #environment.FIND_DISPLAY_OUTPUT = "/tmp/foo"; # to debug the "find display" script
41
42 serviceConfig =
43 { StandardInput = "socket";
44 StandardOutput = "socket";
45 StandardError = "journal";
46 ExecStart = "@${pkgs.x11vnc}/bin/x11vnc x11vnc -inetd -display WAIT:1024x786:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp -unixpw -ssl SAVE";
47 # Don't kill the X server when the user quits the VNC
48 # connection. FIXME: the X server should run in a
49 # separate systemd session.
50 KillMode = "process";
51 };
52 };
53
54 };
55
56}