From 0ec23ed5f0df94ad0da5d380e77258c27d2889b8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 3 Dec 2019 23:56:48 -0500 Subject: [PATCH] Refactor gnupg+pinentry installation Ensure pinentry-gtk-2 is used so we can theme its prompt, and ensure that gpg respects XDG conventions. --- modules/shell/gnupg.nix | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/modules/shell/gnupg.nix b/modules/shell/gnupg.nix index 162f0617..43083d55 100644 --- a/modules/shell/gnupg.nix +++ b/modules/shell/gnupg.nix @@ -1,13 +1,32 @@ { config, lib, pkgs, ... }: { - environment.systemPackages = with pkgs; [ - gnupg - pinentry - ]; + environment = { + extraInit = '' + export GNUPGHOME="$XDG_CONFIG_HOME/gnupg" + if [ ! -d "$GNUPGHOME" ]; then + mkdir -p "$GNUPGHOME" -m 700 + fi + ''; + + systemPackages = with pkgs; [ + gnupg + pinentry + ]; + }; programs.gnupg.agent = { enable = true; enableSSHSupport = true; }; + + systemd.user.services.gpg-agent.serviceConfig.ExecStart = [ + "" '' + ${pkgs.gnupg}/bin/gpg-agent \ + --supervised \ + --allow-emacs-pinentry \ + --default-cache-ttl 1200 \ + --pinentry-program ${pkgs.pinentry}/bin/pinentry-gtk-2 + '' + ]; }