2011-11-10 21:52:23 +01:00
|
|
|
|
# This module implements a terminal service based on ‘x11vnc’. It
|
|
|
|
|
# listens on port 5900 for VNC connections. It then presents a login
|
|
|
|
|
# screen to the user. If the user successfully authenticates, x11vnc
|
|
|
|
|
# checks to see if a X server is already running for that user. If
|
|
|
|
|
# not, a X server (Xvfb) is started for that user. The Xvfb instances
|
|
|
|
|
# persist across VNC sessions.
|
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
2011-11-10 21:52:23 +01:00
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
|
with lib;
|
2011-11-10 21:52:23 +01:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
config = {
|
2013-11-08 16:37:10 +01:00
|
|
|
|
|
2011-11-10 21:52:23 +01:00
|
|
|
|
services.xserver.enable = true;
|
2014-04-29 12:58:54 +02:00
|
|
|
|
services.xserver.videoDrivers = [];
|
2011-11-10 21:52:23 +01:00
|
|
|
|
|
|
|
|
|
# Enable KDM. Any display manager will do as long as it supports XDMCP.
|
|
|
|
|
services.xserver.displayManager.kdm.enable = true;
|
|
|
|
|
services.xserver.displayManager.kdm.enableXDMCP = true;
|
|
|
|
|
services.xserver.displayManager.kdm.extraConfig =
|
|
|
|
|
''
|
|
|
|
|
[General]
|
|
|
|
|
# We're headless, so don't bother starting an X server.
|
|
|
|
|
StaticServers=
|
|
|
|
|
|
|
|
|
|
[Xdmcp]
|
|
|
|
|
Xaccess=${pkgs.writeText "Xaccess" "localhost"}
|
|
|
|
|
'';
|
|
|
|
|
|
2013-11-08 16:37:10 +01:00
|
|
|
|
systemd.sockets.terminal-server =
|
|
|
|
|
{ description = "Terminal Server Socket";
|
|
|
|
|
wantedBy = [ "sockets.target" ];
|
|
|
|
|
before = [ "multi-user.target" ];
|
|
|
|
|
socketConfig.Accept = true;
|
|
|
|
|
socketConfig.ListenStream = 5900;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.services."terminal-server@" =
|
|
|
|
|
{ description = "Terminal Server";
|
|
|
|
|
|
|
|
|
|
path =
|
2017-01-12 16:41:33 +01:00
|
|
|
|
[ pkgs.xorg.xorgserver.out pkgs.gawk pkgs.which pkgs.openssl pkgs.xorg.xauth
|
2013-11-08 16:37:10 +01:00
|
|
|
|
pkgs.nettools pkgs.shadow pkgs.procps pkgs.utillinux pkgs.bash
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
environment.FD_GEOM = "1024x786x24";
|
|
|
|
|
environment.FD_XDMCP_IF = "127.0.0.1";
|
|
|
|
|
#environment.FIND_DISPLAY_OUTPUT = "/tmp/foo"; # to debug the "find display" script
|
|
|
|
|
|
|
|
|
|
serviceConfig =
|
|
|
|
|
{ StandardInput = "socket";
|
|
|
|
|
StandardOutput = "socket";
|
|
|
|
|
StandardError = "journal";
|
|
|
|
|
ExecStart = "@${pkgs.x11vnc}/bin/x11vnc x11vnc -inetd -display WAIT:1024x786:cmd=FINDCREATEDISPLAY-Xvfb.xdmcp -unixpw -ssl SAVE";
|
|
|
|
|
# Don't kill the X server when the user quits the VNC
|
|
|
|
|
# connection. FIXME: the X server should run in a
|
|
|
|
|
# separate systemd session.
|
|
|
|
|
KillMode = "process";
|
|
|
|
|
};
|
2011-11-10 21:52:23 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|