2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.eternal-terminal;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.eternal-terminal = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "Eternal Terminal server";
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
default = 2022;
|
|
|
|
type = types.int;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The port the server should listen on. Will use the server's default (2022) if not specified.
|
|
|
|
|
|
|
|
Make sure to open this port in the firewall if necessary.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
verbosity = mkOption {
|
|
|
|
default = 0;
|
|
|
|
type = types.enum (lib.range 0 9);
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The verbosity level (0-9).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
silent = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
If enabled, disables all logging.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logSize = mkOption {
|
|
|
|
default = 20971520;
|
|
|
|
type = types.int;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The maximum log size.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
# We need to ensure the et package is fully installed because
|
|
|
|
# the (remote) et client runs the `etterminal` binary when it
|
|
|
|
# connects.
|
|
|
|
environment.systemPackages = [ pkgs.eternal-terminal ];
|
|
|
|
|
|
|
|
systemd.services = {
|
|
|
|
eternal-terminal = {
|
|
|
|
description = "Eternal Terminal server.";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2021-12-19 01:06:50 +00:00
|
|
|
after = [ "network.target" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
|
|
|
ExecStart = "${pkgs.eternal-terminal}/bin/etserver --daemon --cfgfile=${pkgs.writeText "et.cfg" ''
|
|
|
|
; et.cfg : Config file for Eternal Terminal
|
|
|
|
;
|
|
|
|
|
|
|
|
[Networking]
|
|
|
|
port = ${toString cfg.port}
|
|
|
|
|
|
|
|
[Debug]
|
|
|
|
verbose = ${toString cfg.verbosity}
|
|
|
|
silent = ${if cfg.silent then "1" else "0"}
|
|
|
|
logsize = ${toString cfg.logSize}
|
|
|
|
''}";
|
|
|
|
Restart = "on-failure";
|
|
|
|
KillMode = "process";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
2022-02-21 08:47:16 +00:00
|
|
|
maintainers = with lib.maintainers; [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|