marleyos/modules/home/programs/gpg/default.nix
2024-11-16 19:38:49 -08:00

38 lines
781 B
Nix

{
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;
};
};
}