{ lib, config, namespace, pkgs, ... }: let inherit (lib) mkIf; inherit (lib.${namespace}) mkEnableModule isDesktop; cfg = config.${namespace}.programs.gpg; in { options = mkEnableModule "programs.gpg"; config = mkIf cfg.enable { # home-manager gpg-agent module doesn't seem to actually install the desired # pinentry program, so we install it here. home.packages = [ config.services.gpg-agent.pinentryPackage ]; programs.gpg = { enable = true; }; services.gpg-agent = rec { enable = true; pinentryPackage = if isDesktop then pkgs.pinentry-gtk2 else pkgs.pinentry-curses; # Don't ask for the password very often. defaultCacheTtl = 60480000; maxCacheTtl = defaultCacheTtl; }; }; }