From 07c023cb185e7c49a04246a686dd2a560bb0d55f Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:48:44 -0600 Subject: btopweb --- hosts/ganymede/config.nix | 4 ++++ hosts/mercury/nixos.nix | 10 ++++++++++ modules/services/nixos/btopweb.nix | 35 +++++++++++++++++++++++++++++++++++ modules/services/nixos/goaccess.nix | 9 ++++----- modules/services/options.nix | 5 +++++ 5 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 modules/services/nixos/btopweb.nix diff --git a/hosts/ganymede/config.nix b/hosts/ganymede/config.nix index 8347e5a..db684ae 100644 --- a/hosts/ganymede/config.nix +++ b/hosts/ganymede/config.nix @@ -65,6 +65,10 @@ enable = true; privateUrl = "stats.ganymede"; }; + btopweb = { + enable = true; + privateUrl = "btop.ganymede"; + }; cgit = { enable = true; diff --git a/hosts/mercury/nixos.nix b/hosts/mercury/nixos.nix index 7884f20..f820b7f 100644 --- a/hosts/mercury/nixos.nix +++ b/hosts/mercury/nixos.nix @@ -1,5 +1,6 @@ { lib, + pkgs, inputs, ... }: { @@ -20,6 +21,15 @@ dataDir = "/home/collin/.local/syncthing"; }; + services.autossh.sessions = [ + { + name = "ganymede"; + user = "collin"; + monitoringPort = 20000; + extraArguments = "-N -D 9090 collin@williamsfam.us.com"; + } + ]; + security.soteria.enable = true; services.printing.enable = true; diff --git a/modules/services/nixos/btopweb.nix b/modules/services/nixos/btopweb.nix new file mode 100644 index 0000000..1975c5d --- /dev/null +++ b/modules/services/nixos/btopweb.nix @@ -0,0 +1,35 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.collinux.services.btopweb; +in { + imports = [ + (import ./mkCaddyCfg.nix cfg) + ]; + + config = lib.mkIf cfg.enable { + users.groups."btopweb" = {}; + users.users."btopweb" = { + isSystemUser = true; + group = "btopweb"; + }; + + systemd.services."btopweb" = { + description = "Host btop on a website"; + restartIfChanged = true; + wants = ["network-online.target"]; + after = ["network-online.target"]; + wantedBy = ["multi-user.target"]; + + serviceConfig = { + User = "btopweb"; + Type = "simple"; + + ExecStart = "${pkgs.gotty}/bin/gotty --reconnect --port ${toString cfg.port} ${pkgs.btop}/bin/btop"; + }; + }; + }; +} diff --git a/modules/services/nixos/goaccess.nix b/modules/services/nixos/goaccess.nix index a71a9c3..f8940c9 100644 --- a/modules/services/nixos/goaccess.nix +++ b/modules/services/nixos/goaccess.nix @@ -15,6 +15,8 @@ date-format = "%s"; log-format = "CADDY"; tz = config.time.timeZone; + log-file = "/var/log/caddy/access-williamsfam.us.com.log"; + geoip-database = geoip; ws-url = if cfg.publicUrl != null @@ -22,16 +24,13 @@ else if cfg.privateUrl != null then "wss://${cfg.privateUrl}:443/ws" else null; - port = "7890"; + port = 7890; addr = cfg.listenAddr; real-time-html = "true"; - log-file = "/var/log/caddy/access-williamsfam.us.com.log"; - geoip-database = geoip; output = "/var/www/goaccess/index.html"; external-assets = "true"; all-static-files = "false"; - html-report-title = "stats@ganymede"; hl-header = "true"; agent-list = "false"; @@ -45,7 +44,7 @@ real-os = "true"; }; - settingsFile = pkgs.writeText "goaccess.conf" (settings |> builtins.mapAttrs (k: v: "${k} ${v}") |> builtins.attrValues |> lib.concatStringsSep "\n"); + settingsFile = pkgs.writeText "goaccess.conf" (settings |> builtins.mapAttrs (k: v: "${k} ${toString v}") |> builtins.attrValues |> lib.concatStringsSep "\n"); in { imports = [ (import ./mkCaddyCfg.nix cfg) diff --git a/modules/services/options.nix b/modules/services/options.nix index eb88e21..bd0a990 100644 --- a/modules/services/options.nix +++ b/modules/services/options.nix @@ -83,6 +83,11 @@ in { default_port = 8010; }; + btopweb = webserviceOptions { + service_name = "btopweb"; + default_port = 8017; + }; + goaccess = webserviceOptions { service_name = "goaccess"; reverse_proxy = false; -- cgit v1.3.1