helm/modules/shell/gnupg.nix

39 lines
974 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;
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 = {
packages = with pkgs; [
gnupg
pinentry
];
env.GNUPGHOME = "$XDG_CONFIG_HOME/gnupg";
};
system.activationScripts.setupGnuPG = "mkdir -p \"${config.my.env.GNUPGHOME}\" -m 700";
2020-03-28 22:48:43 -07:00
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
2020-03-28 22:48:43 -07:00
systemd.user.services.gpg-agent.serviceConfig.ExecStart = [
"" ''
${pkgs.gnupg}/bin/gpg-agent \
--supervised \
--allow-emacs-pinentry \
--default-cache-ttl ${toString gnupgCfg.cacheTTL} \
--pinentry-program ${pkgs.pinentry}/bin/pinentry-gtk-2
''
];
};
2019-08-06 10:56:54 -07:00
}