11 cfg = config.services.x2goserver;
15 enable = cfg.superenicer.enable;
18 confText = generators.toINI { } (recursiveUpdate defaults cfg.settings);
19 x2goServerConf = pkgs.writeText "x2goserver.conf" confText;
21 x2goAgentOptions = pkgs.writeText "x2goagent.options" ''
23 X2GO_NXAGENT_DEFAULT_OPTIONS="${concatStringsSep " " cfg.nxagentDefaultOptions}"
29 (mkRenamedOptionModule [ "programs" "x2goserver" ] [ "services" "x2goserver" ])
32 options.services.x2goserver = {
33 enable = mkEnableOption "x2goserver" // {
35 Enables the x2goserver module.
36 NOTE: This will create a good amount of symlinks in `/usr/local/bin`
41 enable = mkEnableOption "superenicer" // {
43 Enables the SupeReNicer code in x2gocleansessions, this will renice
44 suspended sessions to nice level 19 and renice them to level 0 if the
45 session becomes marked as running again
50 nxagentDefaultOptions = mkOption {
51 type = types.listOf types.str;
57 List of default nx agent options.
62 type = types.attrsOf types.attrs;
65 x2goserver.conf ini configuration as nix attributes. See
66 `x2goserver.conf(5)` for details
68 example = literalExpression ''
72 "idle-nice-level" = 19;
74 telekinesis = { "enable" = "no"; };
80 config = mkIf cfg.enable {
82 # x2goserver can run X11 program even if "services.xserver.enable = false"
84 autostart.enable = true;
90 environment.systemPackages = [ pkgs.x2goserver ];
92 users.groups.x2go = { };
94 home = "/var/lib/x2go/db";
99 security.wrappers.x2gosqliteWrapper = {
100 source = "${pkgs.x2goserver}/lib/x2go/libx2go-server-db-sqlite3-wrapper.pl";
106 security.wrappers.x2goprintWrapper = {
107 source = "${pkgs.x2goserver}/bin/x2goprint";
114 systemd.tmpfiles.rules =
117 "d /var/lib/x2go/ - x2go x2go - -"
118 "d /var/lib/x2go/db - x2go x2go - -"
119 "d /var/lib/x2go/conf - x2go x2go - -"
120 "d /run/x2go 0755 x2go x2go - -"
123 # x2goclient sends SSH commands with preset PATH set to
124 # "/usr/local/bin;/usr/bin;/bin". Since we cannot filter arbitrary ssh
125 # commands, we have to make the following executables available.
126 map (f: "L+ /usr/local/bin/${f} - - - - ${x2goserver}/bin/${f}") [
140 "x2golistsessions_root"
141 "x2golistshadowsessions"
145 "x2goresume-desktopsharing"
148 "x2goserver-run-extensions"
153 "x2gosuspend-desktopsharing"
154 "x2gosuspend-session"
155 "x2goterminate-desktopsharing"
156 "x2goterminate-session"
161 "L+ /usr/local/bin/awk - - - - ${gawk}/bin/awk"
162 "L+ /usr/local/bin/chmod - - - - ${coreutils}/bin/chmod"
163 "L+ /usr/local/bin/cp - - - - ${coreutils}/bin/cp"
164 "L+ /usr/local/bin/sed - - - - ${gnused}/bin/sed"
165 "L+ /usr/local/bin/setsid - - - - ${util-linux}/bin/setsid"
166 "L+ /usr/local/bin/xrandr - - - - ${xorg.xrandr}/bin/xrandr"
167 "L+ /usr/local/bin/xmodmap - - - - ${xorg.xmodmap}/bin/xmodmap"
170 systemd.services.x2goserver = {
171 description = "X2Go Server Daemon";
172 wantedBy = [ "multi-user.target" ];
173 unitConfig.Documentation = "man:x2goserver.conf(5)";
176 ExecStart = "${pkgs.x2goserver}/bin/x2gocleansessions";
177 PIDFile = "/run/x2go/x2goserver.pid";
180 RuntimeDirectory = "x2go";
181 StateDirectory = "x2go";
184 if [ ! -e /var/lib/x2go/setup_ran ]
186 mkdir -p /var/lib/x2go/conf
187 cp -r ${pkgs.x2goserver}/etc/x2go/* /var/lib/x2go/conf/
188 ln -sf ${x2goServerConf} /var/lib/x2go/conf/x2goserver.conf
189 ln -sf ${x2goAgentOptions} /var/lib/x2go/conf/x2goagent.options
190 ${pkgs.x2goserver}/bin/x2godbadmin --createdb
191 touch /var/lib/x2go/setup_ran
196 # https://bugs.x2go.org/cgi-bin/bugreport.cgi?bug=276
197 security.sudo.extraConfig = ''
198 Defaults env_keep+=QT_GRAPHICSSYSTEM
200 security.sudo-rs.extraConfig = ''
201 Defaults env_keep+=QT_GRAPHICSSYSTEM