1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 19:49:45 +01:00

gpg-agent: always export SSH_AUTH_SOCK

When using GnuPG agent for SSH, it is necessary to export the
SSH_AUTH_SOCK variable, otherwise, SSH will use the wrong agent socket.
This commit is contained in:
Ayman Bagabas 2024-09-27 14:40:50 +02:00
parent ffe2d07e77
commit fe9ef570fe
No known key found for this signature in database
GPG key ID: C8D51D2157C919AC

View file

@ -280,8 +280,11 @@ in {
"pinentry-program ${lib.getExe cfg.pinentryPackage}"
++ [ cfg.extraConfig ]);
# Make sure we export GnuPG agent socket for SSH
# https://www.gnupg.org/documentation/manuals/gnupg/Agent-Examples.html#Agent-Examples
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
'';