nixpkgs/nixos/modules/services/networking/eternal-terminal.nix

96 lines
2.1 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.eternal-terminal;
in
{
###### interface
options = {
services.eternal-terminal = {
2018-10-20 21:44:13 +01:00
enable = mkEnableOption "Eternal Terminal server";
port = mkOption {
2018-10-20 21:44:13 +01:00
default = 2022;
type = types.int;
description = ''
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;
2018-10-20 21:44:13 +01:00
type = types.enum (lib.range 0 9);
description = ''
The verbosity level (0-9).
'';
};
2018-10-20 21:44:13 +01:00
silent = mkOption {
default = false;
type = types.bool;
description = ''
2018-10-20 21:44:13 +01:00
If enabled, disables all logging.
'';
};
logSize = mkOption {
default = 20971520;
type = types.int;
description = ''
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" ];
after = [ "syslog.target" "network.target" ];
serviceConfig = {
Type = "forking";
ExecStart = "${pkgs.eternal-terminal}/bin/etserver --daemon --cfgfile=${pkgs.writeText "et.cfg" ''
; et.cfg : Config file for Eternal Terminal
;
2018-10-20 21:44:13 +01:00
[Networking]
port = ${toString cfg.port}
[Debug]
verbose = ${toString cfg.verbosity}
2018-10-25 01:57:33 +01:00
silent = ${if cfg.silent then "1" else "0"}
logsize = ${toString cfg.logSize}
''}";
Restart = "on-failure";
KillMode = "process";
};
};
};
};
meta = {
maintainers = with lib.maintainers; [ pingiun ];
};
}