From a2523ea0343b056ba240abbac90ab5f116a7aa7b Mon Sep 17 00:00:00 2001 From: TornaxO7 Date: Sat, 25 Nov 2023 16:56:07 +0100 Subject: [PATCH] gpg-agent: add nushell integration --- modules/services/gpg-agent.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/services/gpg-agent.nix b/modules/services/gpg-agent.nix index 63ba11c77..9139c8a81 100644 --- a/modules/services/gpg-agent.nix +++ b/modules/services/gpg-agent.nix @@ -22,6 +22,16 @@ let set -gx GPG_TTY (tty) '' + optionalString cfg.enableSshSupport gpgSshSupportStr; + gpgNushellInitStr = '' + $env.GPG_TTY = (tty) + '' + optionalString cfg.enableSshSupport '' + ${gpgPkg}/bin/gpg-connect-agent updatestartuptty /bye | ignore + + if not "SSH_AUTH_SOCK" in $env { + $env.SSH_AUTH_SOCK = (${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket) + } + ''; + # mimic `gpgconf` output for use in `systemd` unit definitions. # we cannot use `gpgconf` directly because it heavily depends on system # state, but we need the values at build time. original: @@ -216,6 +226,10 @@ in { enableFishIntegration = mkEnableOption "Fish integration" // { default = true; }; + + enableNushellIntegration = mkEnableOption "Nushell integration" // { + default = true; + }; }; }; @@ -247,6 +261,9 @@ in { programs.zsh.initExtra = mkIf cfg.enableZshIntegration gpgInitStr; programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration gpgFishInitStr; + + programs.nushell.extraEnv = + mkIf cfg.enableNushellIntegration gpgNushellInitStr; } (mkIf (cfg.sshKeys != null) {