diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 2174fdd793..510c25c030 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -44,7 +44,7 @@ let ''; gpgNushellInitStr = '' - $env.GPG_TTY = (tty) + $env.GPG_TTY = (try { tty } catch { "" }) '' + optionalString cfg.enableSshSupport '' ${gpgSshSupportStr} | ignore diff --git a/tests/modules/services/gpg-agent/ssh-support.nix b/tests/modules/services/gpg-agent/ssh-support.nix index 29016cf863..935ad938a6 100644 --- a/tests/modules/services/gpg-agent/ssh-support.nix +++ b/tests/modules/services/gpg-agent/ssh-support.nix @@ -19,6 +19,9 @@ assertFileContains \ home-files/.config/nushell/config.nu \ '$env.SSH_AUTH_SOCK = $"(@gnupg@/bin/gpgconf --list-dirs agent-ssh-socket)"' + assertFileContains \ + home-files/.config/nushell/config.nu \ + '$env.GPG_TTY = (try { tty } catch { "" })' assertFileContains \ home-files/.zshenv \ 'export SSH_AUTH_SOCK="$(@gnupg@/bin/gpgconf --list-dirs agent-ssh-socket)"'