Skip to content

Commit cf9ff6d

Browse files
authored
wayvnc: init (#7123)
Signed-off-by: Sefa Eyeoglu <[email protected]>
1 parent 8fc1e46 commit cf9ff6d

File tree

8 files changed

+150
-0
lines changed

8 files changed

+150
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{ pkgs, ... }:
2+
{
3+
time = "2025-05-24T18:18:40+00:00";
4+
condition = pkgs.stdenv.hostPlatform.isLinux;
5+
message = ''
6+
A new module is available: `services.wayvnc`
7+
8+
wayvnc is a VNC server for wlroots based Wayland compositors.
9+
'';
10+
}

modules/modules.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ let
470470
./services/vdirsyncer.nix
471471
./services/volnoti.nix
472472
./services/way-displays.nix
473+
./services/wayvnc.nix
473474
./services/window-managers/awesome.nix
474475
./services/window-managers/bspwm/default.nix
475476
./services/window-managers/fluxbox.nix

modules/services/wayvnc.nix

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
inherit (lib)
9+
getExe
10+
literalExpression
11+
mkEnableOption
12+
mkIf
13+
mkOption
14+
mkPackageOption
15+
types
16+
;
17+
18+
cfg = config.services.wayvnc;
19+
20+
format = pkgs.formats.keyValue { };
21+
in
22+
{
23+
meta.maintainers = with lib.maintainers; [ Scrumplex ];
24+
25+
options.services.wayvnc = {
26+
enable = mkEnableOption "wayvnc VNC server";
27+
28+
package = mkPackageOption pkgs "wayvnc" { };
29+
30+
autoStart = mkEnableOption "autostarting of wayvnc";
31+
32+
systemdTarget = mkOption {
33+
type = types.str;
34+
default = config.wayland.systemd.target;
35+
defaultText = literalExpression "config.wayland.systemd.target";
36+
description = ''
37+
Systemd target to bind to.
38+
'';
39+
};
40+
41+
settings = mkOption {
42+
type = types.submodule {
43+
freeformType = format.type;
44+
45+
options = {
46+
address = mkOption {
47+
description = ''
48+
The address to which the server shall bind, e.g. 0.0.0.0 or
49+
localhost.
50+
'';
51+
type = types.str;
52+
example = "0.0.0.0";
53+
};
54+
port = mkOption {
55+
description = ''
56+
The port to which the server shall bind.
57+
'';
58+
type = types.port;
59+
example = 5901;
60+
};
61+
};
62+
};
63+
description = ''
64+
See CONFIGURATION section in {manpage}`wayvnc(1)`.
65+
'';
66+
default = { };
67+
example = {
68+
address = "0.0.0.0";
69+
port = 5901;
70+
};
71+
};
72+
};
73+
74+
config = mkIf cfg.enable {
75+
assertions = [
76+
(lib.hm.assertions.assertPlatform "services.wayvnc" pkgs lib.platforms.linux)
77+
];
78+
79+
systemd.user.services."wayvnc" = {
80+
Unit = {
81+
Description = "wayvnc VNC server";
82+
Documentation = [ "man:wayvnc(1)" ];
83+
After = [ cfg.systemdTarget ];
84+
PartOf = [ cfg.systemdTarget ];
85+
};
86+
Service.ExecStart = [ (getExe cfg.package) ];
87+
Install.WantedBy = lib.mkIf cfg.autoStart [ cfg.systemdTarget ];
88+
};
89+
90+
# For manpage and wayvncctl
91+
home.packages = [ cfg.package ];
92+
93+
xdg.configFile."wayvnc/config".source = format.generate "wayvnc.conf" cfg.settings;
94+
};
95+
}

tests/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ import nmtSrc {
496496
./modules/services/udiskie
497497
./modules/services/volnoti
498498
./modules/services/way-displays
499+
./modules/services/wayvnc
499500
./modules/services/window-managers/bspwm
500501
./modules/services/window-managers/herbstluftwm
501502
./modules/services/window-managers/hyprland
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
wayvnc-simple = ./simple.nix;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
address=0.0.0.0
2+
port=5901
3+
username=foobar
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{ config, ... }:
2+
{
3+
services.wayvnc = {
4+
enable = true;
5+
package = config.lib.test.mkStubPackage { };
6+
7+
autoStart = true;
8+
9+
settings = {
10+
address = "0.0.0.0";
11+
port = 5901;
12+
username = "foobar";
13+
};
14+
};
15+
16+
nmt.script = ''
17+
assertFileExists home-files/.config/systemd/user/wayvnc.service
18+
assertFileContent \
19+
$(normalizeStorePaths home-files/.config/systemd/user/wayvnc.service) \
20+
${./simple.service}
21+
22+
assertFileExists home-files/.config/wayvnc/config
23+
assertFileContent home-files/.config/wayvnc/config ${./simple-config}
24+
'';
25+
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Install]
2+
WantedBy=graphical-session.target
3+
4+
[Service]
5+
ExecStart=/nix/store/00000000000000000000000000000000-dummy/bin/dummy
6+
7+
[Unit]
8+
After=graphical-session.target
9+
Description=wayvnc VNC server
10+
Documentation=man:wayvnc(1)
11+
PartOf=graphical-session.target

0 commit comments

Comments
 (0)