1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-01 06:31:04 +01:00
home-manager/modules/services/wayvnc.nix
Austin Horstman 86402a17b6 treewide: flatten single file modules
Some files don't need nesting and can be root level again to reduce
conflicts with other PRs.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-23 16:20:26 -05:00

95 lines
2.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
getExe
literalExpression
mkEnableOption
mkIf
mkOption
mkPackageOption
types
;
cfg = config.services.wayvnc;
format = pkgs.formats.keyValue { };
in
{
meta.maintainers = with lib.maintainers; [ Scrumplex ];
options.services.wayvnc = {
enable = mkEnableOption "wayvnc VNC server";
package = mkPackageOption pkgs "wayvnc" { };
autoStart = mkEnableOption "autostarting of wayvnc";
systemdTarget = mkOption {
type = types.str;
default = config.wayland.systemd.target;
defaultText = literalExpression "config.wayland.systemd.target";
description = ''
Systemd target to bind to.
'';
};
settings = mkOption {
type = types.submodule {
freeformType = format.type;
options = {
address = mkOption {
description = ''
The address to which the server shall bind, e.g. 0.0.0.0 or
localhost.
'';
type = types.str;
example = "0.0.0.0";
};
port = mkOption {
description = ''
The port to which the server shall bind.
'';
type = types.port;
example = 5901;
};
};
};
description = ''
See CONFIGURATION section in {manpage}`wayvnc(1)`.
'';
default = { };
example = {
address = "0.0.0.0";
port = 5901;
};
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.wayvnc" pkgs lib.platforms.linux)
];
systemd.user.services."wayvnc" = {
Unit = {
Description = "wayvnc VNC server";
Documentation = [ "man:wayvnc(1)" ];
After = [ cfg.systemdTarget ];
PartOf = [ cfg.systemdTarget ];
};
Service.ExecStart = [ (getExe cfg.package) ];
Install.WantedBy = lib.mkIf cfg.autoStart [ cfg.systemdTarget ];
};
# For manpage and wayvncctl
home.packages = [ cfg.package ];
xdg.configFile."wayvnc/config".source = format.generate "wayvnc.conf" cfg.settings;
};
}