Pass says "No pinentry"

I get the following error when I use pass.

gpg: decryption failed: no pinentry

I run on NixOS 24.05.4997.086b448a5d54 (Uakari).
Here are the relevant parts in my /etc/nixos/configuration.nix.

environment.systemPackages = with pkgs; [
# ...
  pass
# ...
  ];

# ...

programs.gnupg.agent = {
    enable = true;
    pinentryPackage = with pkgs; pinentry-all;
    enableSSHSupport = true;
  };

This has been a recurring issue every time I upgrade NixOS. This time, the upgrade notified me to change the programs.gnupg.agent.pinentryFlavor option to programs.gnupg.agent.pinentryPackage which I did as above.

I was using pass-wayland with pinentry-gnome3 without any issue on NixOS 23.11. I changed to pass and pinentry-all for debugging this issue.

Very curious, so, I am interested in feedbacks!

What happens if you remove the pinentryPackage line? In general, it tries to pick the best suitable one: nixpkgs/nixos/modules/programs/gnupg.nix at 944b2aea7f0a2d7c79f72468106bc5510cbf5101 · NixOS/nixpkgs · GitHub

Thanks for your reply.
I tried removing the pinentryPackage line, and the same issue persists after I sudo nixos-rebuild switch.

I got an idea and tried to

nix shell nixpkgs#pinentry-all nixpkgs#pass

but the nix shell still has the same issue. The actual error message is in French because of my system locales.

❯ pass bandcamp.com 
gpg: échec du déchiffrement par clef publique : Pas de pinentry
gpg: échec du déchiffrement : Pas de pinentry

EDIT: This is my /etc/nixos/configuration.nix.

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Nix settings.
  nix = {
    package = pkgs.nixFlakes;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';
  };

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";

  networking.hostName = "izm"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
  networking.interfaces.enp4s0f4u1.wakeOnLan.enable = true;

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Asia/Tokyo";
  # time.timeZone = "Europe/Paris";

  # Select internationalisation properties.
  i18n.defaultLocale = "fr_FR.utf8";

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  services.teamviewer.enable = true;
  services.xserver.wacom.enable = true;

  services.logind.lidSwitchExternalPower = "lock";
  services.ratbagd.enable = true;
  virtualisation.virtualbox.host.enable = false;
  # virtualisation.libvirtd.enable = true;
  # programs.dconf.enable = true;
  # environment.systemPackages = with pkgs; [ virt-manager ];
  # users.users.adam.extraGroups = [ "libvirtd" ];
  virtualisation.docker.enable = false;

  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
    dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
  };

  programs.kdeconnect.enable = true;

  # nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [
  #   "steam"
  #   "steam-original"
  #   "steam-runtime"
  # ];

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
 #  services.xserver.displayManager.session = [{
 #      manage = "window";
 #      name = "xmonad";
 #      start = ''
 #        ${pkgs.runtimeShell} $HOME/.xsession &
 #        waitPID=$!
 #      '';
 #    }];
  # Configure keymap in X11
  services.xserver = {
    xkb.layout = "jp";
    xkb.variant = "";
  };

  # Configure console keymap
  console.keyMap = "jp106";

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Fonts
  fonts.packages = with pkgs; [
    fira-code
    fira-code-symbols
    noto-fonts
    noto-fonts-cjk
    noto-fonts-emoji
    liberation_ttf
    mplus-outline-fonts.githubRelease
    dina-font
    proggyfonts
    # iosevka
  ];
  # Enable sound with pipewire.
  sound.enable = false;
  hardware.pulseaudio.enable = false;
  hardware.sane.enable = true;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  programs.fish.enable = true;
  environment.shells = with pkgs; [ fish ];

#  users.users.adam-test = {
#    isNormalUser = true;
#    extraGroups = [ "libvirtd" "networkmanager" "wheel" "audio" ];
#  };
  
  users.users.adam = {
    isNormalUser = true;
    description = "adam";
    extraGroups = [ "libvirtd" "networkmanager" "wheel" "audio" "docker" "vboxusers" ];
    shell = pkgs.fish;
  };

  i18n.inputMethod = {
  enabled = "ibus";
  ibus.engines = with pkgs.ibus-engines; [ anthy hangul mozc ];
  };
  
  nixpkgs.config.allowUnfree = true;
  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  virt-manager 
  vim # Nano is installed by default.
  wget
  openssh
  ntfs3g
  emacs29-gtk3
  # iosevka
  pass
  ];

  systemd.services.battery-charge-threshold = {
    description = "Set the battery charge threshold";
    wantedBy = ["multi-user.target"];
    after = ["multi-user.target"];
    startLimitBurst = 0;
    script = ''
    echo 60 > /sys/class/power_supply/BATT/charge_control_end_threshold
    '';
    serviceConfig = {
      Type = "oneshot";
      Restart = "on-failure";
   };
  };
    
  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  programs.gnupg.agent = {
    enable = true;
    # pinentryPackage = with pkgs; pinentry-all;
    enableSSHSupport = true;
  };
  services.pcscd.enable = true;
 
  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  services.openssh = {
    enable = true;
    # require public key authentication for better security
    settings.PasswordAuthentication = false;
    settings.KbdInteractiveAuthentication = false;
    #settings.PermitRootLogin = "yes";
    settings.Macs = [
      "hmac-sha2-512-etm@openssh.com"
      "hmac-sha2-256-etm@openssh.com"
      "umac-128-etm@openssh.com"
      "hmac-sha2-512"
      ];
  };

  # # Open ports in the firewall.
  networking.firewall.allowedTCPPorts = [ 23 ];
  # # networking.firewall.allowedUDPPorts = [ ... ];
  # # Or disable the firewall altogether.
  # # networking.firewall.enable = false;

  # # This value determines the NixOS release from which the default
  # # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "22.05"; # Did you read the comment?

}

Do you have a gpg agent config?

ls ~/.gnupg/gpg-agent.conf

Make sure it’s not setting any pinentry-program there. And have you tried setting it to pinentry-gnome3 already instead?

1 Like

That’s the solution! Thank you!
I can’t remember when I added this line to my gpg-agent.conf, and even forgot the existence of this file.

pinentry-program /run/current-system/sw/bin/pinentry

I completely removed the file and now it works as expected. I did not bother to put any pinentryPackage in the configuration.nix and the defaults work too.