2023-06-16 19:12:42 +02:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.services.guacamole-server;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.guacamole-server = {
|
2024-04-13 14:54:15 +02:00
|
|
|
enable = lib.mkEnableOption "Apache Guacamole Server (guacd)";
|
2023-11-30 19:03:14 +01:00
|
|
|
package = lib.mkPackageOption pkgs "guacamole-server" { };
|
2023-06-16 19:12:42 +02:00
|
|
|
|
|
|
|
extraEnvironment = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf lib.types.str;
|
|
|
|
default = { };
|
|
|
|
example = lib.literalExpression ''
|
|
|
|
{
|
|
|
|
ENVIRONMENT = "production";
|
|
|
|
}
|
|
|
|
'';
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Environment variables to pass to guacd.";
|
2023-06-16 19:12:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
host = lib.mkOption {
|
|
|
|
default = "127.0.0.1";
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2023-06-16 19:12:42 +02:00
|
|
|
The host name or IP address the server should listen to.
|
|
|
|
'';
|
|
|
|
type = lib.types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
port = lib.mkOption {
|
|
|
|
default = 4822;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2023-06-16 19:12:42 +02:00
|
|
|
The port the guacd server should listen to.
|
|
|
|
'';
|
|
|
|
type = lib.types.port;
|
|
|
|
};
|
|
|
|
|
|
|
|
logbackXml = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.path;
|
|
|
|
default = null;
|
|
|
|
example = "/path/to/logback.xml";
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2023-06-16 19:12:42 +02:00
|
|
|
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";
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2023-06-16 19:12:42 +02:00
|
|
|
Configuration file that correspond to `user-mapping.xml`.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
# Setup configuration files.
|
|
|
|
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; };
|
|
|
|
|
|
|
|
systemd.services.guacamole-server = {
|
|
|
|
description = "Apache Guacamole server (guacd)";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
environment = {
|
|
|
|
HOME = "/run/guacamole-server";
|
|
|
|
} // cfg.extraEnvironment;
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${lib.getExe cfg.package} -f -b ${cfg.host} -l ${toString cfg.port}";
|
|
|
|
RuntimeDirectory = "guacamole-server";
|
|
|
|
DynamicUser = true;
|
|
|
|
PrivateTmp = "yes";
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|