1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

fix(service/gpg-agent): ensure SSH_AUTH_SOCK is set on Darwin (#7117)

This commit addresses https://github.com/nix-community/home-manager/issues/5997
At the root, the gpg-agent SSH integration is not working on Darwin
because shells are started with `SSH_AUTH_SOCK` already set to something
like `/private/tmp/com.apple.launchd.ozLmoURHDC/Listeners`, which
prevents the hook from setting the variable to the gpg-agent's socket.

This commit fixes the issue using a different mechanism to detect if the
current shell has already had the `SSH_AUTH_SOCK` variable set to the
gpg-agent's socket, namely by checking for `gnupg_SSH_AUTH_SOCK_by` as
documented in
https://www.gnupg.org/documentation/manuals/gnupg/Agent-Examples.html#Agent-Examples.

This is essentially a simplified version of
https://github.com/nix-community/home-manager/pull/5901 that does not
attempt to migrate gpg-agent over to launchd.

Signed-off-by: squat <lserven@gmail.com>
This commit is contained in:
Lucas Servén Marín 2025-06-28 19:30:46 +02:00 committed by GitHub
parent 080e8b48b0
commit da077f20db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -371,7 +371,8 @@ in
);
home.sessionVariablesExtra = optionalString cfg.enableSshSupport ''
if [ -z "$SSH_AUTH_SOCK" ]; then
unset SSH_AGENT_PID
if [ "''${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)"
fi
'';