kopecky.io

NixOS - working GPG config with home-manager

2024-02-25

I was trying to get GPG working on my NixOS setup with home-manager, but I was running into issues with pinentry. I was getting the following error:

gpg: problem with the agent: No pinentry

The issue was that I installed gpg as a package in my home configuration and not as a program.

  home.packages = with pkgs; [
    ...
    gnupg
    ...
  ];

I changed the config to install gpg as a program and also and configured gpg-agent to use curses as the pinentry program:

  # gpg
  programs.gpg.enable = true;

  # gpg-agent
  services.gpg-agent = {
    enable = true;
    enableSshSupport = true;
    enableBashIntegration = true;
    pinentryFlavor = "curses";
  };

But I was still getting the same error, even though others solved the issue with this config (except they were using gnome3 flavor). Found out that I had to also reboot the computer and now it works seamlessly!

Thanks to guys discussing this issue: