From de6010990361926048d729009ce1637a997782b3 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Tue, 9 Sep 2025 18:13:27 -0400 Subject: [PATCH] Add gotty web service, and use it in sensuous (#97) --- configurations/home/srid@sensuous.nix | 7 ++++ modules/home/all/gotty.nix | 52 +++++++++++++++++++++++++++ modules/home/default.nix | 1 + 3 files changed, 60 insertions(+) create mode 100644 modules/home/all/gotty.nix diff --git a/configurations/home/srid@sensuous.nix b/configurations/home/srid@sensuous.nix index 08a41e0..91ba181 100644 --- a/configurations/home/srid@sensuous.nix +++ b/configurations/home/srid@sensuous.nix @@ -11,4 +11,11 @@ in ]; home.username = "srid"; + + services.gotty = { + enable = true; + port = 9000; + command = "tmux new-session -A -s gotty"; + write = true; + }; } diff --git a/modules/home/all/gotty.nix b/modules/home/all/gotty.nix new file mode 100644 index 0000000..a596487 --- /dev/null +++ b/modules/home/all/gotty.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.gotty; +in +{ + options.services.gotty = { + enable = mkEnableOption "GoTTY web terminal service"; + + port = mkOption { + type = types.int; + default = 8080; + description = "Port number for GoTTY to listen on"; + }; + + command = mkOption { + type = types.str; + default = "${pkgs.bash}/bin/bash"; + description = "Command to execute in the terminal"; + }; + + write = mkOption { + type = types.bool; + default = false; + description = "Allow clients to write to the terminal"; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.gotty ]; + + systemd.user.services.gotty = { + Unit = { + Description = "GoTTY web terminal service"; + After = [ "network.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${pkgs.gotty}/bin/gotty -p ${toString cfg.port}${optionalString cfg.write " -w"} ${cfg.command}"; + Restart = "always"; + RestartSec = 5; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; +} diff --git a/modules/home/default.nix b/modules/home/default.nix index a2f7016..387aecc 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -12,6 +12,7 @@ # ./all/zellij.nix ./all/just.nix # ./all/juspay.nix + ./all/gotty.nix ./claude-code ];