11 cfg = config.services.networking.websockify;
15 services.networking.websockify = {
17 description = "Whether to enable websockify to forward websocket connections to TCP connections.";
25 description = "Path to the SSL certificate.";
30 description = "Path to the SSL key.";
31 default = cfg.sslCert;
32 defaultText = literalExpression "config.services.networking.websockify.sslCert";
37 description = "Ports to map by default.";
39 type = types.attrsOf types.int;
44 config = mkIf cfg.enable {
45 systemd.services."websockify@" = {
46 description = "Service to forward websocket connections to TCP connections (from port:to port %I)";
48 IFS=':' read -a array <<< "$1"
49 ${pkgs.python3Packages.websockify}/bin/websockify --ssl-only \
50 --cert=${cfg.sslCert} --key=${cfg.sslKey} 0.0.0.0:''${array[0]} 0.0.0.0:''${array[1]}
55 systemd.targets.default-websockify = {
56 description = "Target to start all default websockify@ services";
57 unitConfig.X-StopOnReconfiguration = true;
58 wants = mapAttrsToList (name: value: "websockify@${name}:${toString value}.service") cfg.portMap;
59 wantedBy = [ "multi-user.target" ];