Commit 67eff987002f

Vincent Demeester <vincent@sbr.pm>
2026-01-12 16:23:55
fix(shpool): use helper script for claude sessions + restrict IdentityAgent
- Create claude-vertex helper script that shpool -c can execute as binary - shpool -c expects binary+args, not shell commands - Set IdentityAgent=none only for aomi.home (not all .home hosts) - Helper script sets Vertex AI env vars and execs claude
1 parent 3d9a785
Changed files (2)
lib
tools
shpool-ssh-wrapper
lib/functions.nix
@@ -155,8 +155,8 @@ let
               else
                 x;
             forwardAgent = true;
-            # Disable IdentityAgent for .home hosts (prevents yubikey prompts in TRAMP)
-            extraOptions = lib.optionalAttrs (lib.strings.hasSuffix ".home" x) {
+            # Disable IdentityAgent only for aomi.home (prevents yubikey prompts in TRAMP)
+            extraOptions = lib.optionalAttrs (x == "aomi.home") {
               IdentityAgent = "none";
             };
           };
tools/shpool-ssh-wrapper/default.nix
@@ -1,5 +1,15 @@
 { pkgs }:
 
+let
+  # Helper script to start Claude Code with Vertex AI environment
+  claude-vertex = pkgs.writeShellScript "claude-vertex" ''
+    export CLAUDE_CODE_USE_VERTEX=1
+    export CLOUD_ML_REGION=us-east5
+    export ANTHROPIC_VERTEX_PROJECT_ID=itpc-gcp-pnd-pe-eng-claude
+    exec claude
+  '';
+in
+
 pkgs.writeScriptBin "shpool-ssh-wrapper" ''
   #!${pkgs.bash}/bin/bash
   # Shpool SSH wrapper - automatically runs commands for specific session patterns
@@ -20,8 +30,8 @@ pkgs.writeScriptBin "shpool-ssh-wrapper" ''
   case "$SESSION_NAME" in
       claude/*)
           # Claude Code session - run with Vertex AI environment
-          # Run via shell to get proper PATH and environment
-          run_with_command "$SESSION_NAME" "zsh -l -c 'env CLAUDE_CODE_USE_VERTEX=1 CLOUD_ML_REGION=us-east5 ANTHROPIC_VERTEX_PROJECT_ID=itpc-gcp-pnd-pe-eng-claude claude'"
+          # Use helper script since shpool -c expects a binary, not a shell command
+          run_with_command "$SESSION_NAME" "${claude-vertex}"
           ;;
       *)
           # Default: just attach to session with default shell