Commit d7112bdb865f
Changed files (5)
home
common
shell
pkgs
systems
common
base
tools
shpool-ssh-wrapper
home/common/shell/default.nix
@@ -47,6 +47,7 @@
ripgrep
# shpool is enabled via services.shpool
+ # shpool-ssh-wrapper is installed system-wide (needed on remote hosts)
# ugrep
scripts
wol
home/common/shell/openssh.nix
@@ -50,7 +50,7 @@
else
id;
extraOptions = {
- RemoteCommand = "shpool attach -f $(echo '%k' | cut -d/ -f2-)";
+ RemoteCommand = "shpool-ssh-wrapper $(echo '%k' | cut -d/ -f2-)";
RequestTTY = "yes";
};
};
pkgs/default.nix
@@ -12,6 +12,7 @@ in
# TODO: migrate things from nix/packages
nixfmt-plus = pkgs.callPackage ./nixfmt-plus.nix { };
scripts = pkgs.callPackage ./my/scripts { };
+ shpool-ssh-wrapper = pkgs.callPackage ../tools/shpool-ssh-wrapper { };
vrsync = pkgs.callPackage ./my/vrsync { };
vde-thinkpad = pkgs.callPackage ./my/vde-thinkpad { };
battery-monitor = pkgs.callPackage ../tools/battery-monitor { };
systems/common/base/default.nix
@@ -42,6 +42,7 @@
pv
ripgrep
rsync
+ shpool-ssh-wrapper # For smart shpool SSH session management
traceroute
tree
usbutils
tools/shpool-ssh-wrapper/default.nix
@@ -0,0 +1,30 @@
+{ pkgs }:
+
+pkgs.writeScriptBin "shpool-ssh-wrapper" ''
+ #!${pkgs.bash}/bin/bash
+ # Shpool SSH wrapper - automatically runs commands for specific session patterns
+
+ set -euo pipefail
+
+ # Get the session name from SSH original command (e.g., "aomi.home/claude/session1" -> "claude/session1")
+ SESSION_NAME="''${1}"
+
+ # Function to run shpool with a specific command
+ run_with_command() {
+ local session="$1"
+ local cmd="$2"
+ exec ${pkgs.shpool}/bin/shpool attach -f -c "$cmd" "$session"
+ }
+
+ # Check session name patterns and run appropriate commands
+ case "$SESSION_NAME" in
+ claude/*)
+ # Claude Code session - run with Vertex AI environment
+ run_with_command "$SESSION_NAME" "env CLAUDE_CODE_USE_VERTEX=1 CLOUD_ML_REGION=us-east5 ANTHROPIC_VERTEX_PROJECT_ID=itpc-gcp-pnd-pe-eng-claude claude"
+ ;;
+ *)
+ # Default: just attach to session with default shell
+ exec ${pkgs.shpool}/bin/shpool attach -f "$SESSION_NAME"
+ ;;
+ esac
+''