helm/modules/shell/gnupg.nix

31 lines
878 B
Nix
Raw Normal View History

2020-03-28 22:48:43 -07:00
{ config, options, lib, pkgs, ... }:
2019-08-06 10:56:54 -07:00
2020-03-28 22:48:43 -07:00
with lib;
let cfg = config.modules;
gnupgCfg = cfg.shell.gnupg;
2020-04-22 16:52:48 -07:00
homedir = "$XDG_CONFIG_HOME/gnupg";
2020-03-28 22:48:43 -07:00
in {
options.modules.shell.gnupg = {
enable = mkOption { type = types.bool; default = false; };
cacheTTL = mkOption { type = types.int; default = 1800; };
};
2019-08-06 10:56:54 -07:00
2020-03-28 22:48:43 -07:00
config = mkIf gnupgCfg.enable {
my = {
2020-04-22 16:52:48 -07:00
env.GNUPGHOME = homedir;
2020-03-28 22:48:43 -07:00
2020-04-22 16:52:48 -07:00
# HACK Without this config file you get "No pinentry program" on 20.03.
# program.gnupg.agent.pinentryFlavor doesn't appear to work, and this
# is cleaner than overriding the systemd unit.
home.xdg.configFile."gnupg/gpg-agent.conf" = {
text = ''
default-cache-ttl ${toString gnupgCfg.cacheTTL}
pinentry-program ${pkgs.pinentry.gtk2}/bin/pinentry
'';
};
};
2020-04-27 16:20:50 -07:00
programs.gnupg.agent.enable = true;
2020-03-28 22:48:43 -07:00
};
2019-08-06 10:56:54 -07:00
}