From 62d157800cd054398cc330f9d4dd3398d983c607 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Thu, 8 Jan 2026 08:41:16 -0600 Subject: [PATCH] Improving nushell ssh-agent support --- home/baseline/nushell.nix | 30 ++++++++++++++++++++++++++++++ home/default.nix | 1 + home/hosts/ivr/default.nix | 2 ++ 3 files changed, 33 insertions(+) diff --git a/home/baseline/nushell.nix b/home/baseline/nushell.nix index 5699fdb..20678d5 100644 --- a/home/baseline/nushell.nix +++ b/home/baseline/nushell.nix @@ -46,6 +46,36 @@ in let otp = ^bw get totp 10371487-7f40-4b08-9a45-b33e00de318b osascript ${vpn} $login.login.username $"($login.login.password)($otp)" } + + # From the nushell cookbook: https://www.nushell.sh/cookbook/ssh_agent.html#keychain + do --env { + let ssh_agent_file = ( + $nu.temp-path | path join $"ssh-agent-(whoami).nuon" + ) + + if ($ssh_agent_file | path exists) { + let ssh_agent_env = open ($ssh_agent_file) + if (ps | find --columns [pid] $ssh_agent_env.SSH_AGENT_PID | is-not-empty) { + load-env $ssh_agent_env + print $"Agent found, and loading ($ssh_agent_env)" + print $env.SSH_AUTH_SOCK + return + } else { + print "Agent not found, removing file and starting again" + rm $ssh_agent_file + } + } + + let ssh_agent_env = ^ssh-agent -c + | lines + | first 2 + | parse "setenv {name} {value};" + | transpose --header-row + | into record + print $"Starting agent ($ssh_agent_env)" + load-env $ssh_agent_env + $ssh_agent_env | save --force $ssh_agent_file + } ''; settings = { buffer_editor = lib.getExe config.programs.nixvim.package; diff --git a/home/default.nix b/home/default.nix index c51f739..a76945c 100644 --- a/home/default.nix +++ b/home/default.nix @@ -33,6 +33,7 @@ in { "MacBook-Pro.local" = user "ivr" "gregory.hellings"; "MacBook-Prolocal.local" = user "ivr" "gregory.hellings"; + "MacBook-Pro.thehellings.lan" = user "ivr" "gregory.hellings"; genesis = greg "genesis"; exodus = greg "exodus"; zeke = greg "zeke"; diff --git a/home/hosts/ivr/default.nix b/home/hosts/ivr/default.nix index 3bf489c..f1041a0 100644 --- a/home/hosts/ivr/default.nix +++ b/home/hosts/ivr/default.nix @@ -32,6 +32,7 @@ in ansible direnv home-manager + python3Packages.ipython just go gopls @@ -47,6 +48,7 @@ in python311 python3Packages.flake8 skaffold + twine x ]; file = {