nixos/gnupg: set SSH_AUTH_SOCK in non-interactive settings

`SSH_AUTH_SOCK` is useful in some non-interactive settings, for instance
daemonized Emacs. Fixes #55733.
This commit is contained in:
Emanuel Evans 2019-02-23 10:20:12 -08:00
parent bea06ac613
commit ddabdc0a1e
No known key found for this signature in database
GPG Key ID: 1E4F32B35B2005E1

View File

@ -85,11 +85,13 @@ in
# SSH agent protocol doesn't support changing TTYs, so bind the agent
# to every new TTY.
${pkgs.gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null
'');
environment.extraInit = mkIf cfg.agent.enableSSHSupport ''
if [ -z "$SSH_AUTH_SOCK" ]; then
export SSH_AUTH_SOCK=$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)
fi
'');
'';
assertions = [
{ assertion = cfg.agent.enableSSHSupport -> !config.programs.ssh.startAgent;