summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/web-apps/guacamole-client.nix
blob: 54ca2f4f3be7381e2ea336bac073d59e56ea114b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.services.guacamole-client;
  settingsFormat = pkgs.formats.javaProperties { };
in
{
  options = {
    services.guacamole-client = {
      enable = lib.mkEnableOption "Apache Guacamole Client (Tomcat)";
      package = lib.mkPackageOption pkgs "guacamole-client" { };

      settings = lib.mkOption {
        type = lib.types.submodule {
          freeformType = settingsFormat.type;
        };
        default = {
          guacd-hostname = "localhost";
          guacd-port = 4822;
        };
        description = ''
          Configuration written to `guacamole.properties`.

          ::: {.note}
          The Guacamole web application uses one main configuration file called
          `guacamole.properties`. This file is the common location for all
          configuration properties read by Guacamole or any extension of
          Guacamole, including authentication providers.
          :::
        '';
      };

      enableWebserver = lib.mkOption {
        type = lib.types.bool;
        default = true;
        description = ''
          Enable the Guacamole web application in a Tomcat webserver.
        '';
      };

      logbackXml = lib.mkOption {
        type = lib.types.nullOr lib.types.path;
        default = null;
        example = "/path/to/logback.xml";
        description = ''
          Configuration file that correspond to `logback.xml`.
        '';
      };

      userMappingXml = lib.mkOption {
        type = lib.types.nullOr lib.types.path;
        default = null;
        example = "/path/to/user-mapping.xml";
        description = ''
          Configuration file that correspond to `user-mapping.xml`.
        '';
      };
    };
  };

  config = lib.mkIf cfg.enable {
    # Setup configuration files.
    environment.etc."guacamole/guacamole.properties" = lib.mkIf (cfg.settings != { }) {
      source = (settingsFormat.generate "guacamole.properties" cfg.settings);
    };
    environment.etc."guacamole/logback.xml" = lib.mkIf (cfg.logbackXml != null) {
      source = cfg.logbackXml;
    };
    environment.etc."guacamole/user-mapping.xml" = lib.mkIf (cfg.userMappingXml != null) {
      source = cfg.userMappingXml;
    };

    services = lib.mkIf cfg.enableWebserver {
      tomcat = {
        enable = true;
        webapps = [
          cfg.package
        ];
      };
    };
  };
}