Gpg not decrypting

I am trying to do a room on tryhackme and it uses gpg and openssl. when I do the decryption I get the following:
[termg@nixos:~/Downloads/intro-to-cryptography/task02]$ gpg --output quote01-decrypted.txt --decrypt quote01.txt.gpg
gpg: AES256.CFB encrypted data
gpg: problem with the agent: No pinentry
gpg: encrypted with 1 passphrase
gpg: decryption failed: Bad session key

So I installed pinentry just in case it needs it and it still does not work. I tried “nix-env -iA”, which looked like it ran but the issue was not fixed. I am guessing I am just forgetting to install something but I can’t find any installation instructions and it shouldn’t be that difficult. Also I did do the rebuild switch and reboot so it is not that.

[termg@nixos:~/Downloads/intro-to-cryptography/task02]$ gpg --output quote01-decrypted.txt --decrypt quote01.txt.gpg --passphrase s!kR3T55
bash: !kR3T55: event not found
This was an attempt to bypass the password entering thingy. Did not work.

I have this in my home-manager configuration.

 services.gpg-agent = {
   enable = true;
   pinentryPackage =  pkgs.pinentry-gnome3;
 };

And this in my system configuration

services.dbus.packages = [ pkgs.gcr ];

pkgs.gcr is only needed if your not on gnome according to the home-configurationnix man page
https://nix-community.github.io/home-manager/options.xhtml#opt-services.gpg-agent.pinentryPackage

This works for me

If you don’t use home-manger, putting this into your system configuration should also work

programs.gnupg.agent = {
  enable = true;
  pinentryPackage = pkgs.pinentry-gnome3;
}

I have KDE. I assume I just take off the gnome parts?

you don’t have to use gnome to use pinentry-gnome3. I use sway and it works. You can also use other pinentry programs they all start with pinentry- (NixOS Search)