nixos/guacamole-server: init

This commit is contained in:
Pol Dellaiera 2023-06-16 19:12:42 +02:00
parent a950888024
commit 6cc1b175d3
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA
5 changed files with 110 additions and 0 deletions

View File

@ -1194,6 +1194,7 @@
./services/web-apps/grocy.nix
./services/web-apps/pixelfed.nix
./services/web-apps/guacamole-client.nix
./services/web-apps/guacamole-server.nix
./services/web-apps/healthchecks.nix
./services/web-apps/hedgedoc.nix
./services/web-apps/hledger-web.nix

View File

@ -0,0 +1,83 @@
{ config
, lib
, pkgs
, ...
}:
let
cfg = config.services.guacamole-server;
in
{
options = {
services.guacamole-server = {
enable = lib.mkEnableOption (lib.mdDoc "Apache Guacamole Server (guacd)");
package = lib.mkPackageOptionMD pkgs "guacamole-server" { };
extraEnvironment = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
example = lib.literalExpression ''
{
ENVIRONMENT = "production";
}
'';
description = lib.mdDoc "Environment variables to pass to guacd.";
};
host = lib.mkOption {
default = "127.0.0.1";
description = lib.mdDoc ''
The host name or IP address the server should listen to.
'';
type = lib.types.str;
};
port = lib.mkOption {
default = 4822;
description = lib.mdDoc ''
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";
description = lib.mdDoc ''
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 = lib.mdDoc ''
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";
};
};
};
}

View File

@ -315,6 +315,7 @@ in {
grocy = handleTest ./grocy.nix {};
grub = handleTest ./grub.nix {};
guacamole-client = handleTest ./guacamole-client.nix {};
guacamole-server = handleTest ./guacamole-server.nix {};
gvisor = handleTest ./gvisor.nix {};
hadoop = import ./hadoop { inherit handleTestOn; package=pkgs.hadoop; };
hadoop_3_2 = import ./hadoop { inherit handleTestOn; package=pkgs.hadoop_3_2; };

View File

@ -0,0 +1,21 @@
import ./make-test-python.nix ({pkgs, lib, ...}:
{
name = "guacamole-server";
nodes = {
machine = {pkgs, ...}: {
services.guacamole-server = {
enable = true;
host = "0.0.0.0";
};
};
};
testScript = ''
start_all()
machine.wait_for_unit("guacamole-server.service")
machine.wait_for_open_port(4822)
'';
meta.maintainers = [ lib.maintainers.drupol ];
})

View File

@ -81,6 +81,10 @@ stdenv.mkDerivation (finalAttrs: {
wrapProgram $out/sbin/guacd --prefix LD_LIBRARY_PATH ":" $out/lib
'';
passthru.tests = {
inherit (nixosTests) guacamole-server;
};
meta = {
description = "Clientless remote desktop gateway";
homepage = "https://guacamole.apache.org/";