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-12-03 20:56:48 -08:00
|
|
|
};
|
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";
|
|
|
|
};
|
|
|
|
|
2020-04-05 22:57:44 -07:00
|
|
|
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;
|
|
|
|
};
|
2019-12-03 20:56:48 -08:00
|
|
|
|
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
|
|
|
}
|