Add wayvnc option for sway

This change allows you to start wayvnc anytime your sway session starts.
For hosts where you want to enable this, you'll need to generate the
certificate and keys, see:

https://github.com/any1/wayvnc#encryption--authentication

You can then add these to your secrets via agenix, and load them as
`vnc-key.pem` and `vnc-cert.pem` into `/run/secrets`.

Enable the wayvnc server via the option `pub-solar.sway.vnc.enable`.

At the time of writing, `tigervnc` appears to be a good vnc client to
use.

```
This commit is contained in:
Benjamin Bädorf 2022-04-28 23:20:18 +02:00
parent 895cdc30b9
commit 06ca86f9c9
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
4 changed files with 43 additions and 5 deletions

View file

@ -47,3 +47,9 @@ mode "$mode_system" {
bindsym Return mode "default"
bindsym Escape mode "default"
}
set $mode_vncclient In VNCClient mode. Press $mod+Num_Lock to return.
bindsym $mod+Num_Lock mode "$mode_vncclient"
mode "$mode_vncclient" {
bindsym $mod+Num_Lock mode "default"
}

View file

@ -0,0 +1,8 @@
{ psCfg, pkgs }: "
address=0.0.0.0
enable_auth=true
username=${psCfg.user.name}
password=${psCfg.user.password}
private_key_file=/run/secrets/vnc-key.pem
certificate_file=/run/secrets/vnc-cert.pem
"

View file

@ -7,12 +7,14 @@ in
{
options.pub-solar.sway = {
enable = mkEnableOption "Life in boxes";
};
options.pub-solar.sway.v4l2loopback.enable = mkOption {
vnc.enable = mkEnableOption "Enable vnc service";
v4l2loopback.enable = mkOption {
type = types.bool;
default = true;
description = "WebCam streaming tool";
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf (cfg.v4l2loopback.enable) {
@ -76,6 +78,8 @@ in
systemd.user.services.waybar = import ./waybar.service.nix pkgs;
systemd.user.targets.sway-session = import ./sway-session.target.nix pkgs;
systemd.user.services.wayvnc = mkIf cfg.vnc.enable (import ./wayvnc.service.nix pkgs);
xdg.configFile."sway/config".source = ./config/config;
xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf;
xdg.configFile."sway/config.d/theme.conf".source = ./config/config.d/theme.conf;
@ -83,6 +87,7 @@ in
xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.conf;
xdg.configFile."sway/config.d/applications.conf".source = ./config/config.d/applications.conf;
xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.conf;
xdg.configFile."wayvnc/config".text = import ./config/wayvnc/config.nix { inherit psCfg; inherit pkgs; };
};
})
]);

View file

@ -0,0 +1,19 @@
pkgs:
{
Unit = {
Description = "A VNC server for wlroots based Wayland compositors ";
Documentation = "https://github.com/any1/wayvnc";
BindsTo = [ "sway-session.target" ];
After = [ "graphical-session-pre.target" "network-online.target" ];
Wants = [ "graphical-session-pre.target" "network-online.target" ];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.wayvnc}/bin/wayvnc";
};
Install = {
WantedBy = [ "sway-session.target" ];
};
}