From af1a28501701f56b7289e8e3d855e638272d2a3d Mon Sep 17 00:00:00 2001 From: qolii Date: Fri, 19 Oct 2018 17:36:38 -0700 Subject: nixos/eternal-terminal: init new module. --- nixos/modules/module-list.nix | 1 + .../services/networking/eternal-terminal.nix | 96 ++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 nixos/modules/services/networking/eternal-terminal.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index fb6b4262568e..6305b0fa9eb5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -504,6 +504,7 @@ ./services/networking/dnsmasq.nix ./services/networking/ejabberd.nix ./services/networking/epmd.nix + ./services/networking/eternal-terminal.nix ./services/networking/fakeroute.nix ./services/networking/ferm.nix ./services/networking/firefox/sync-server.nix diff --git a/nixos/modules/services/networking/eternal-terminal.nix b/nixos/modules/services/networking/eternal-terminal.nix new file mode 100644 index 000000000000..aa9d399a4a3a --- /dev/null +++ b/nixos/modules/services/networking/eternal-terminal.nix @@ -0,0 +1,96 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.eternal-terminal; + +in + +{ + + ###### interface + + options = { + + services.eternal-terminal = { + + enable = mkOption { + default = false; + type = types.bool; + description = '' + Enable the Eternal Terminal server. + ''; + }; + + port = mkOption { + default = null; + type = types.nullOr types.int; + description = '' + The port the server should listen on. Will use the server's default (2022) if not specified. + ''; + }; + + verbosity = mkOption { + default = 0; + type = types.int; + description = '' + The verbosity level (0-9). + ''; + }; + + silence = mkOption { + default = 0; + type = types.int; + description = '' + Silence. + ''; + }; + + 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 + ; + + ${optionalString (cfg.port != null) '' + [Networking] + port = ${toString cfg.port} + ''} + [Debug] + verbose = ${toString cfg.verbosity} + silent = ${toString cfg.silence} + logsize = ${toString cfg.logSize} + ''}"; + Restart = "on-failure"; + KillMode = "process"; + }; + }; + }; + }; +} -- cgit 1.4.1 From ee0444576ff01d40fe734137c298104cac8ca705 Mon Sep 17 00:00:00 2001 From: qolii Date: Sat, 20 Oct 2018 13:44:13 -0700 Subject: Address review feedback. --- .../services/networking/eternal-terminal.nix | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/nixos/modules/services/networking/eternal-terminal.nix b/nixos/modules/services/networking/eternal-terminal.nix index aa9d399a4a3a..1d2dc5d23b97 100644 --- a/nixos/modules/services/networking/eternal-terminal.nix +++ b/nixos/modules/services/networking/eternal-terminal.nix @@ -16,17 +16,11 @@ in services.eternal-terminal = { - enable = mkOption { - default = false; - type = types.bool; - description = '' - Enable the Eternal Terminal server. - ''; - }; + enable = mkEnableOption "Eternal Terminal server"; port = mkOption { - default = null; - type = types.nullOr types.int; + default = 2022; + type = types.int; description = '' The port the server should listen on. Will use the server's default (2022) if not specified. ''; @@ -34,17 +28,17 @@ in verbosity = mkOption { default = 0; - type = types.int; + type = types.enum (lib.range 0 9); description = '' The verbosity level (0-9). ''; }; - silence = mkOption { - default = 0; - type = types.int; + silent = mkOption { + default = false; + type = types.bool; description = '' - Silence. + If enabled, disables all logging. ''; }; @@ -78,13 +72,12 @@ in ; et.cfg : Config file for Eternal Terminal ; - ${optionalString (cfg.port != null) '' - [Networking] - port = ${toString cfg.port} - ''} + [Networking] + port = ${toString cfg.port} + [Debug] verbose = ${toString cfg.verbosity} - silent = ${toString cfg.silence} + silent = ${if cfg.silent then "true" else "false"} logsize = ${toString cfg.logSize} ''}"; Restart = "on-failure"; -- cgit 1.4.1 From c0d90b57d68e8973c4bd94244cac0bf07a0368ff Mon Sep 17 00:00:00 2001 From: qolii Date: Wed, 24 Oct 2018 17:57:33 -0700 Subject: Address more review feedback. --- nixos/modules/services/networking/eternal-terminal.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/eternal-terminal.nix b/nixos/modules/services/networking/eternal-terminal.nix index 1d2dc5d23b97..be7337ece7e4 100644 --- a/nixos/modules/services/networking/eternal-terminal.nix +++ b/nixos/modules/services/networking/eternal-terminal.nix @@ -77,7 +77,7 @@ in [Debug] verbose = ${toString cfg.verbosity} - silent = ${if cfg.silent then "true" else "false"} + silent = ${if cfg.silent then "1" else "0"} logsize = ${toString cfg.logSize} ''}"; Restart = "on-failure"; -- cgit 1.4.1