···
{ config, lib, pkgs, ... }:
cfg = config.services.ttyd;
# Command line arguments for the ttyd daemon
args = [ "--port" (toString cfg.port) ]
···
-
enable = mkEnableOption (lib.mdDoc "ttyd daemon");
-
description = lib.mdDoc "Port to listen on (use 0 for random port)";
type = types.nullOr types.path;
example = "/var/run/ttyd.sock";
-
description = lib.mdDoc "UNIX domain socket path to bind.";
type = types.nullOr types.str;
-
description = lib.mdDoc "Network interface to bind.";
type = types.nullOr types.str;
-
description = lib.mdDoc "Username for basic authentication.";
passwordFile = mkOption {
type = types.nullOr types.path;
apply = value: if value == null then null else toString value;
-
description = lib.mdDoc ''
File containing the password to use for basic authentication.
For insecurely putting the password in the globally readable store use
`pkgs.writeText "ttydpw" "MyPassword"`.
···
-
description = lib.mdDoc "Signal to send to the command on session close.";
type = types.nullOr types.bool;
default = null; # null causes an eval error, forcing the user to consider attack surface
-
description = lib.mdDoc "Allow clients to write to the TTY.";
clientOptions = mkOption {
type = types.attrsOf types.str;
-
example = literalExpression ''
fontFamily = "Fira Code";
-
description = lib.mdDoc ''
Attribute set of client options for xtermjs.
<https://xtermjs.org/docs/api/terminal/interfaces/iterminaloptions/>
···
terminalType = mkOption {
default = "xterm-256color";
-
description = lib.mdDoc "Terminal type to report.";
-
description = lib.mdDoc "Whether to allow a websocket connection from a different origin.";
-
description = lib.mdDoc "Maximum clients to support (0, no limit)";
type = types.nullOr types.path;
-
description = lib.mdDoc "Custom index.html path";
-
description = lib.mdDoc "Whether or not to enable IPv6 support.";
-
description = lib.mdDoc "Whether or not to enable SSL (https) support.";
type = types.nullOr types.path;
-
description = lib.mdDoc "SSL certificate file path.";
type = types.nullOr types.path;
apply = value: if value == null then null else toString value;
-
description = lib.mdDoc ''
For insecurely putting the keyFile in the globally readable store use
`pkgs.writeText "ttydKeyFile" "SSLKEY"`.
···
type = types.nullOr types.path;
-
description = lib.mdDoc "SSL CA file path for client certificate verification.";
-
description = lib.mdDoc "Set log level.";
-
config = mkIf cfg.enable {
[ { assertion = cfg.enableSSL
···
script = if cfg.passwordFile != null then ''
PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/TTYD_PASSWORD_FILE")
${pkgs.ttyd}/bin/ttyd ${lib.escapeShellArgs args} \
-
--credential ${escapeShellArg cfg.username}:"$PASSWORD" \