at 24.11-pre 2.3 kB view raw
1{ config 2, lib 3, pkgs 4, ... 5}: 6let 7 cfg = config.services.guacamole-server; 8in 9{ 10 options = { 11 services.guacamole-server = { 12 enable = lib.mkEnableOption "Apache Guacamole Server (guacd)"; 13 package = lib.mkPackageOption pkgs "guacamole-server" { }; 14 15 extraEnvironment = lib.mkOption { 16 type = lib.types.attrsOf lib.types.str; 17 default = { }; 18 example = lib.literalExpression '' 19 { 20 ENVIRONMENT = "production"; 21 } 22 ''; 23 description = "Environment variables to pass to guacd."; 24 }; 25 26 host = lib.mkOption { 27 default = "127.0.0.1"; 28 description = '' 29 The host name or IP address the server should listen to. 30 ''; 31 type = lib.types.str; 32 }; 33 34 port = lib.mkOption { 35 default = 4822; 36 description = '' 37 The port the guacd server should listen to. 38 ''; 39 type = lib.types.port; 40 }; 41 42 logbackXml = lib.mkOption { 43 type = lib.types.nullOr lib.types.path; 44 default = null; 45 example = "/path/to/logback.xml"; 46 description = '' 47 Configuration file that correspond to `logback.xml`. 48 ''; 49 }; 50 51 userMappingXml = lib.mkOption { 52 type = lib.types.nullOr lib.types.path; 53 default = null; 54 example = "/path/to/user-mapping.xml"; 55 description = '' 56 Configuration file that correspond to `user-mapping.xml`. 57 ''; 58 }; 59 }; 60 }; 61 62 config = lib.mkIf cfg.enable { 63 # Setup configuration files. 64 environment.etc."guacamole/logback.xml" = lib.mkIf (cfg.logbackXml != null) { source = cfg.logbackXml; }; 65 environment.etc."guacamole/user-mapping.xml" = lib.mkIf (cfg.userMappingXml != null) { source = cfg.userMappingXml; }; 66 67 systemd.services.guacamole-server = { 68 description = "Apache Guacamole server (guacd)"; 69 wantedBy = [ "multi-user.target" ]; 70 after = [ "network.target" ]; 71 environment = { 72 HOME = "/run/guacamole-server"; 73 } // cfg.extraEnvironment; 74 serviceConfig = { 75 ExecStart = "${lib.getExe cfg.package} -f -b ${cfg.host} -l ${toString cfg.port}"; 76 RuntimeDirectory = "guacamole-server"; 77 DynamicUser = true; 78 PrivateTmp = "yes"; 79 Restart = "on-failure"; 80 }; 81 }; 82 }; 83}