Skip to content

Commit

Permalink
nixos/gnupg: set SSH_AUTH_SOCK in non-interactive settings
Browse files Browse the repository at this point in the history
`SSH_AUTH_SOCK` is useful in some non-interactive settings, for instance
daemonized Emacs. Fixes NixOS#55733.
  • Loading branch information
shosti committed Feb 23, 2019
1 parent bea06ac commit ddabdc0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nixos/modules/programs/gnupg.nix
Expand Up @@ -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;
Expand Down

0 comments on commit ddabdc0

Please sign in to comment.