at master 1.9 kB view raw
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.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 35 pkgs.gawk 36 pkgs.which 37 pkgs.openssl 38 pkgs.xorg.xauth 39 pkgs.net-tools 40 pkgs.shadow 41 pkgs.procps 42 pkgs.util-linux 43 pkgs.bash 44 ]; 45 46 environment.FD_GEOM = "1024x786x24"; 47 environment.FD_XDMCP_IF = "127.0.0.1"; 48 #environment.FIND_DISPLAY_OUTPUT = "/tmp/foo"; # to debug the "find display" script 49 50 serviceConfig = { 51 StandardInput = "socket"; 52 StandardOutput = "socket"; 53 StandardError = "journal"; 54 ExecStart = "@${pkgs.x11vnc}/bin/x11vnc x11vnc -inetd -display WAIT:1024x786:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp -unixpw -ssl SAVE"; 55 # Don't kill the X server when the user quits the VNC 56 # connection. FIXME: the X server should run in a 57 # separate systemd session. 58 KillMode = "process"; 59 }; 60 }; 61 62 }; 63 64}