about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2020-08-20 13:18:23 +0200
committerProfpatsch <mail@profpatsch.de>2020-08-20 14:25:46 +0200
commit1b1e1c43c7bb44e8c7115b34cd1adbf750ebb981 (patch)
tree34cd4e8547f5bc3c8dc088e8201d5c260bb05f4f /modules
parent9a5910eb3c4d082d838cb84273c6423422501c28 (diff)
modules/profpatsch/weechat: add a workaround to attach ssh directly
So far we directly start a mosh-daemon when the user connects.
This breaks down in situations where UDP is blocked (e.g. some
hotspots). In that case, ssh can be used directly:

Example:

    ssh -t weechat@legosi ssh

The ssh argument tells it to connect directly.
Note the `-t`, which forces a pseudo-tty, otherwise tmux will
complain that it can’t find a terminal.
Diffstat (limited to 'modules')
-rw-r--r--modules/user/profpatsch/programs/weechat.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/user/profpatsch/programs/weechat.nix b/modules/user/profpatsch/programs/weechat.nix
index 51574a9b..317f63ec 100644
--- a/modules/user/profpatsch/programs/weechat.nix
+++ b/modules/user/profpatsch/programs/weechat.nix
@@ -21,7 +21,7 @@ let
   bins = getBins pkgs.tmux [ "tmux" ]
     // getBins pkgs.weechat [ "weechat" ]
     // getBins pkgs.dash [ "dash" ]
-    // getBins pkgs.s6-portable-utils [ "s6-sleep" ]
+    // getBins pkgs.s6-portable-utils [ "s6-sleep" "s6-test" ]
     // getBins pkgs.mosh [ "mosh-server" ]
     ;
 
@@ -51,7 +51,11 @@ let
   ];
 
   attachWeechatTmuxSession = writeExecline "attach-weechat-tmux-session" {} [
-    # make sure that we can use mosh here
+    "importas" "-u" "-D" "" "what" "SSH_ORIGINAL_COMMAND"
+    # if the user passes "ssh" as argv, it will call tmux directly
+    "ifelse" [ bins.s6-test "$what" "=" "ssh" ]
+    [ bins.tmux "attach-session" "-t" sessionName ]
+    # if not, it uses the mosh-server (default)
     bins.mosh-server "--"
       bins.tmux
         "attach-session"