at 16.09-beta 2.2 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{ config, lib, pkgs, ... }: 9 10with lib; 11 12{ 13 14 config = { 15 16 services.xserver.enable = true; 17 services.xserver.videoDrivers = []; 18 19 # Enable KDM. Any display manager will do as long as it supports XDMCP. 20 services.xserver.displayManager.kdm.enable = true; 21 services.xserver.displayManager.kdm.enableXDMCP = true; 22 services.xserver.displayManager.kdm.extraConfig = 23 '' 24 [General] 25 # We're headless, so don't bother starting an X server. 26 StaticServers= 27 28 [Xdmcp] 29 Xaccess=${pkgs.writeText "Xaccess" "localhost"} 30 ''; 31 32 systemd.sockets.terminal-server = 33 { description = "Terminal Server Socket"; 34 wantedBy = [ "sockets.target" ]; 35 before = [ "multi-user.target" ]; 36 socketConfig.Accept = true; 37 socketConfig.ListenStream = 5900; 38 }; 39 40 systemd.services."terminal-server@" = 41 { description = "Terminal Server"; 42 43 path = 44 [ pkgs.xorgserver.out pkgs.gawk pkgs.which pkgs.openssl pkgs.xorg.xauth 45 pkgs.nettools pkgs.shadow pkgs.procps pkgs.utillinux pkgs.bash 46 ]; 47 48 environment.FD_GEOM = "1024x786x24"; 49 environment.FD_XDMCP_IF = "127.0.0.1"; 50 #environment.FIND_DISPLAY_OUTPUT = "/tmp/foo"; # to debug the "find display" script 51 52 serviceConfig = 53 { StandardInput = "socket"; 54 StandardOutput = "socket"; 55 StandardError = "journal"; 56 ExecStart = "@${pkgs.x11vnc}/bin/x11vnc x11vnc -inetd -display WAIT:1024x786:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp -unixpw -ssl SAVE"; 57 # Don't kill the X server when the user quits the VNC 58 # connection. FIXME: the X server should run in a 59 # separate systemd session. 60 KillMode = "process"; 61 }; 62 }; 63 64 }; 65 66}