9 cfg = config.services.kasmweb;
12 options.services.kasmweb = {
13 enable = lib.mkEnableOption "kasmweb";
15 networkSubnet = lib.mkOption {
16 default = "172.20.0.0/16";
19 The network subnet to use for the containers.
28 Username to use for the postgres database.
31 password = lib.mkOption {
35 password to use for the postgres database.
40 redisPassword = lib.mkOption {
44 password to use for the redis cache.
48 defaultAdminPassword = lib.mkOption {
52 default admin password to use.
56 defaultUserPassword = lib.mkOption {
60 default user password to use.
64 defaultManagerToken = lib.mkOption {
68 default manager token to use.
72 defaultGuacToken = lib.mkOption {
76 default guac token to use.
80 defaultRegistrationToken = lib.mkOption {
84 default registration token to use.
88 datastorePath = lib.mkOption {
90 default = "/var/lib/kasmweb";
92 The directory used to store all data for kasmweb.
96 listenAddress = lib.mkOption {
100 The address on which kasmweb should listen.
104 listenPort = lib.mkOption {
105 type = lib.types.int;
108 The port on which kasmweb should listen.
112 sslCertificate = lib.mkOption {
113 type = lib.types.nullOr lib.types.path;
116 The SSL certificate to be used for kasmweb.
120 sslCertificateKey = lib.mkOption {
121 type = lib.types.nullOr lib.types.path;
124 The SSL certificate's key to be used for kasmweb. Make sure to specify
125 this as a string and not a literal path, so that it is not accidentally
126 included in your nixstore.
131 config = lib.mkIf cfg.enable {
135 "docker-kasm_db.service"
136 "podman-kasm_db.service"
138 wants = [ "network-online.target" ];
139 after = [ "network-online.target" ];
142 TimeoutStartSec = 300;
143 ExecStart = pkgs.replaceVarsWith {
144 src = ./initialize_kasmweb.sh;
147 binPath = lib.makeBinPath [
153 runtimeShell = pkgs.runtimeShell;
154 kasmweb = pkgs.kasmweb;
155 postgresUser = "postgres";
156 postgresPassword = "postgres";
166 defaultRegistrationToken
176 oci-containers.backend = "docker";
177 oci-containers.containers = {
179 image = "postgres:16-alpine";
182 POSTGRES_PASSWORD = "postgres";
183 POSTGRES_USER = "postgres";
184 POSTGRES_DB = "kasm";
187 "${cfg.datastorePath}/conf/database/data.sql:/docker-entrypoint-initdb.d/data.sql"
188 "${cfg.datastorePath}/conf/database/:/tmp/"
189 "kasmweb_db:/var/lib/postgresql/data"
191 extraOptions = [ "--network=kasm_default_network" ];
194 image = "kasmweb/api:${pkgs.kasmweb.version}";
198 "${cfg.datastorePath}/:/opt/kasm/current/"
199 "kasmweb_api_data:/tmp"
201 dependsOn = [ "kasm_db" ];
202 entrypoint = "/bin/bash";
203 cmd = [ "/opt/kasm/current/init_seeds.sh" ];
205 "--network=kasm_default_network"
210 image = "redis:5-alpine";
211 entrypoint = "/bin/sh";
215 "redis-server --requirepass ${cfg.redisPassword}"
218 "--network=kasm_default_network"
223 image = "kasmweb/api:${pkgs.kasmweb.version}";
227 "${cfg.datastorePath}/:/opt/kasm/current/"
228 "kasmweb_api_data:/tmp"
230 dependsOn = [ "kasm_db_init" ];
232 "--network=kasm_default_network"
237 image = "kasmweb/manager:${pkgs.kasmweb.version}";
241 "${cfg.datastorePath}/:/opt/kasm/current/"
249 "--network=kasm_default_network"
255 image = "kasmweb/agent:${pkgs.kasmweb.version}";
259 "${cfg.datastorePath}/:/opt/kasm/current/"
260 "/var/run/docker.sock:/var/run/docker.sock"
261 "${pkgs.docker}/bin/docker:/usr/bin/docker"
262 "${cfg.datastorePath}/conf/nginx:/etc/nginx/conf.d"
264 dependsOn = [ "kasm_manager" ];
266 "--network=kasm_default_network"
272 image = "kasmweb/share:${pkgs.kasmweb.version}";
276 "${cfg.datastorePath}/:/opt/kasm/current/"
284 "--network=kasm_default_network"
290 image = "kasmweb/kasm-guac:${pkgs.kasmweb.version}";
294 "${cfg.datastorePath}/:/opt/kasm/current/"
301 "--network=kasm_default_network"
307 image = "kasmweb/nginx:latest";
309 ports = [ "${cfg.listenAddress}:${toString cfg.listenPort}:443" ];
312 "${cfg.datastorePath}/conf/nginx:/etc/nginx/conf.d:ro"
313 "${cfg.datastorePath}/certs/kasm_nginx.key:/etc/ssl/private/kasm_nginx.key"
314 "${cfg.datastorePath}/certs/kasm_nginx.crt:/etc/ssl/certs/kasm_nginx.crt"
315 "${cfg.datastorePath}/www:/srv/www:ro"
316 "${cfg.datastorePath}/log/nginx:/var/log/external/nginx"
317 "${cfg.datastorePath}/log/logrotate:/var/log/external/logrotate"
327 "--network=kasm_default_network"
329 "--network-alias=proxy"