1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.guacamole-client;
9 settingsFormat = pkgs.formats.javaProperties { };
10in
11{
12 options = {
13 services.guacamole-client = {
14 enable = lib.mkEnableOption "Apache Guacamole Client (Tomcat)";
15 package = lib.mkPackageOption pkgs "guacamole-client" { };
16
17 settings = lib.mkOption {
18 type = lib.types.submodule {
19 freeformType = settingsFormat.type;
20 };
21 default = {
22 guacd-hostname = "localhost";
23 guacd-port = 4822;
24 };
25 description = ''
26 Configuration written to `guacamole.properties`.
27
28 ::: {.note}
29 The Guacamole web application uses one main configuration file called
30 `guacamole.properties`. This file is the common location for all
31 configuration properties read by Guacamole or any extension of
32 Guacamole, including authentication providers.
33 :::
34 '';
35 };
36
37 enableWebserver = lib.mkOption {
38 type = lib.types.bool;
39 default = true;
40 description = ''
41 Enable the Guacamole web application in a Tomcat webserver.
42 '';
43 };
44 };
45 };
46
47 config = lib.mkIf cfg.enable {
48 environment.etc."guacamole/guacamole.properties" = lib.mkIf (cfg.settings != { }) {
49 source = (settingsFormat.generate "guacamole.properties" cfg.settings);
50 };
51
52 services = lib.mkIf cfg.enableWebserver {
53 tomcat = {
54 enable = true;
55 webapps = [
56 cfg.package
57 ];
58 };
59 };
60 };
61}