These are the standard commands:
gpgconf --list-dirs
gpgconf --kill gpg-agent
gpgconf --reload gpg-agentIf you have enabled the programs.gnupg.agent.enable = true; in NixOS use these instead:
systemctl --user status gpg-agent
systemctl --user reload gpg-agent
systemctl --user restart gpg-agentThe sockets will be opened at /run/user/UID/gnupg instead of the normal location of ~/.gnupg.
Note that there should be a gpg-agent per user (including the root user). Check with this:
ps -Af | grep gpgUsing gpg as root has some complications especially if you entered via sudo -i (login environment). The problem is that the tty is still not owned by the root user, so pinentry programs will fail. You need to ensure that your $(tty) is owned by the root user or instead use the option --pinentry-mode=loopback when running gpg2. See this: https://wiki.archlinux.org/index.php/GnuPG#su