1 { config, lib, pkgs, ... }:
4 cfg = config.services.kasmweb;
7 options.services.kasmweb = {
8 enable = lib.mkEnableOption "kasmweb";
10 networkSubnet = lib.mkOption {
11 default = "172.20.0.0/16";
14 The network subnet to use for the containers.
23 Username to use for the postgres database.
26 password = lib.mkOption {
30 password to use for the postgres database.
35 redisPassword = lib.mkOption {
39 password to use for the redis cache.
43 defaultAdminPassword = lib.mkOption {
47 default admin password to use.
51 defaultUserPassword = lib.mkOption {
55 default user password to use.
59 defaultManagerToken = lib.mkOption {
63 default manager token to use.
67 defaultGuacToken = lib.mkOption {
71 default guac token to use.
75 defaultRegistrationToken = lib.mkOption {
79 default registration token to use.
83 datastorePath = lib.mkOption {
85 default = "/var/lib/kasmweb";
87 The directory used to store all data for kasmweb.
91 listenAddress = lib.mkOption {
95 The address on which kasmweb should listen.
99 listenPort = lib.mkOption {
100 type = lib.types.int;
103 The port on which kasmweb should listen.
107 sslCertificate = lib.mkOption {
108 type = lib.types.nullOr lib.types.path;
111 The SSL certificate to be used for kasmweb.
115 sslCertificateKey = lib.mkOption {
116 type = lib.types.nullOr lib.types.path;
119 The SSL certificate's key to be used for kasmweb. Make sure to specify
120 this as a string and not a literal path, so that it is not accidentally
121 included in your nixstore.
126 config = lib.mkIf cfg.enable {
130 "docker-kasm_db.service"
131 "podman-kasm_db.service"
133 wants = ["network-online.target"];
134 after = ["network-online.target"];
137 TimeoutStartSec = 300;
138 ExecStart = pkgs.substituteAll {
139 src = ./initialize_kasmweb.sh;
141 binPath = lib.makeBinPath [ pkgs.docker pkgs.openssl pkgs.gnused pkgs.yq-go ];
142 runtimeShell = pkgs.runtimeShell;
143 kasmweb = pkgs.kasmweb;
144 postgresUser = "postgres";
145 postgresPassword = "postgres";
155 defaultRegistrationToken
163 oci-containers.backend = "docker";
164 oci-containers.containers = {
166 image = "postgres:16-alpine";
169 POSTGRES_PASSWORD = "postgres";
170 POSTGRES_USER = "postgres";
171 POSTGRES_DB = "kasm";
174 "${cfg.datastorePath}/conf/database/data.sql:/docker-entrypoint-initdb.d/data.sql"
175 "${cfg.datastorePath}/conf/database/:/tmp/"
176 "kasmweb_db:/var/lib/postgresql/data"
178 extraOptions = [ "--network=kasm_default_network" ];
181 image = "kasmweb/api:${pkgs.kasmweb.version}";
185 "${cfg.datastorePath}/:/opt/kasm/current/"
186 "kasmweb_api_data:/tmp"
188 dependsOn = [ "kasm_db" ];
189 entrypoint = "/bin/bash";
190 cmd = [ "/opt/kasm/current/init_seeds.sh" ];
191 extraOptions = [ "--network=kasm_default_network" "--userns=host" ];
194 image = "redis:5-alpine";
195 entrypoint = "/bin/sh";
199 "redis-server --requirepass ${cfg.redisPassword}"
201 extraOptions = [ "--network=kasm_default_network" "--userns=host" ];
204 image = "kasmweb/api:${pkgs.kasmweb.version}";
208 "${cfg.datastorePath}/:/opt/kasm/current/"
209 "kasmweb_api_data:/tmp"
211 dependsOn = [ "kasm_db_init" ];
212 extraOptions = [ "--network=kasm_default_network" "--userns=host" ];
215 image = "kasmweb/manager:${pkgs.kasmweb.version}";
219 "${cfg.datastorePath}/:/opt/kasm/current/"
221 dependsOn = [ "kasm_db_init" "kasm_db" "kasm_api" ];
222 extraOptions = [ "--network=kasm_default_network" "--userns=host" "--read-only"];
225 image = "kasmweb/agent:${pkgs.kasmweb.version}";
229 "${cfg.datastorePath}/:/opt/kasm/current/"
230 "/var/run/docker.sock:/var/run/docker.sock"
231 "${pkgs.docker}/bin/docker:/usr/bin/docker"
232 "${cfg.datastorePath}/conf/nginx:/etc/nginx/conf.d"
234 dependsOn = [ "kasm_manager" ];
235 extraOptions = [ "--network=kasm_default_network" "--userns=host" "--read-only" ];
238 image = "kasmweb/share:${pkgs.kasmweb.version}";
242 "${cfg.datastorePath}/:/opt/kasm/current/"
244 dependsOn = [ "kasm_db_init" "kasm_db" "kasm_redis" ];
245 extraOptions = [ "--network=kasm_default_network" "--userns=host" "--read-only" ];
248 image = "kasmweb/kasm-guac:${pkgs.kasmweb.version}";
252 "${cfg.datastorePath}/:/opt/kasm/current/"
254 dependsOn = [ "kasm_db" "kasm_redis" ];
255 extraOptions = [ "--network=kasm_default_network" "--userns=host" "--read-only" ];
258 image = "kasmweb/nginx:latest";
260 ports = [ "${cfg.listenAddress}:${toString cfg.listenPort}:443" ];
263 "${cfg.datastorePath}/conf/nginx:/etc/nginx/conf.d:ro"
264 "${cfg.datastorePath}/certs/kasm_nginx.key:/etc/ssl/private/kasm_nginx.key"
265 "${cfg.datastorePath}/certs/kasm_nginx.crt:/etc/ssl/certs/kasm_nginx.crt"
266 "${cfg.datastorePath}/www:/srv/www:ro"
267 "${cfg.datastorePath}/log/nginx:/var/log/external/nginx"
268 "${cfg.datastorePath}/log/logrotate:/var/log/external/logrotate"
270 dependsOn = [ "kasm_manager" "kasm_api" "kasm_agent" "kasm_share"
272 extraOptions = [ "--network=kasm_default_network" "--userns=host"
273 "--network-alias=proxy"];