Skip to content

Instantly share code, notes, and snippets.

@lheckemann
Created February 12, 2020 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lheckemann/7fc08afb4ebfbfe6f969c2f1dbf2e811 to your computer and use it in GitHub Desktop.
Save lheckemann/7fc08afb4ebfbfe6f969c2f1dbf2e811 to your computer and use it in GitHub Desktop.
Unfinished and hacky, please don't judge
{ pkgs, lib, config, ... }: let
i3Config = pkgs.writeText "i3-minimal.conf" ''
# i3 config file (v4)
set $mod Mod4
floating_modifier $mod
font pango:monospace 8
bindsym $mod+f fullscreen toggle
default_border none
'';
cfg = config.services.vnc-thinclient;
in {
options = {
services.vnc-thinclient = {
user = lib.mkOption {
type = lib.types.string;
description = "User to run the VNC client as";
default = "vnc";
};
server = lib.mkOption {
type = lib.types.string;
description = "VNC server to connect to";
};
extraOptions = lib.mkOption {
type = lib.types.list lib.types.string;
description = "Extra command-line options passed to vncviewer";
};
};
};
config = {
users.users.${cfg.user} = {};
services.xserver = {
enable = true;
displayManager.auto = {
enable = true;
user = cfg.user;
};
windowManager.i3.enable = true;
};
systemd.services.vncviewer = {
wantedBy = ["multi-user.target"];
after = ["display-manager.service"];
path = [ pkgs.tigervnc pkgs.coreutils pkgs.xorg.xset ];
serviceConfig = {
User = cfg.user;
Restart = "always";
};
script = ''
set -x
export \
DISPLAY=:0 \
XAUTHORITY=${config.users.users.${cfg.user}.home}/.Xauthority
until xset -q >/dev/null; do sleep 1; done
vncviewer \
-FullScreen \
-AlertOnFatalError=off \
${lib.escapeShellArgs cfg.extraOptions} \
${lib.escapeShellArg cfg.server}
'';
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment