From 7026e1a934abfa02623c9870378dbcdac3cd7f80 Mon Sep 17 00:00:00 2001 From: Dixon Sean Low Yan Feng Date: Sun, 8 Jan 2023 12:44:21 +0800 Subject: [PATCH] gpg-agent: fix SSH support for fish --- modules/services/gpg-agent.nix | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index ca70406f..fb59d709 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -9,11 +9,18 @@ let homedir = config.programs.gpg.homedir; + gpgSshSupportStr = '' + ${gpgPkg}/bin/gpg-connect-agent updatestartuptty /bye > /dev/null + ''; + gpgInitStr = '' GPG_TTY="$(tty)" export GPG_TTY - '' + optionalString cfg.enableSshSupport - "${gpgPkg}/bin/gpg-connect-agent updatestartuptty /bye > /dev/null"; + '' + optionalString cfg.enableSshSupport gpgSshSupportStr; + + gpgFishInitStr = '' + set -gx GPG_TTY (tty) + '' + optionalString cfg.enableSshSupport gpgSshSupportStr; # mimic `gpgconf` output for use in `systemd` unit definitions. # we cannot use `gpgconf` directly because it heavily depends on system @@ -238,9 +245,8 @@ in { programs.bash.initExtra = mkIf cfg.enableBashIntegration gpgInitStr; programs.zsh.initExtra = mkIf cfg.enableZshIntegration gpgInitStr; - programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' - set -gx GPG_TTY (tty) - ''; + programs.fish.interactiveShellInit = + mkIf cfg.enableFishIntegration gpgFishInitStr; } (mkIf (cfg.sshKeys != null) {