From 0b1015ebe11582821f435edda99a71b6fb8642a7 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 16 Nov 2024 17:26:48 -0800 Subject: [PATCH] feat(home): GnuPG --- homes/x86_64-linux/marley@nyx/default.nix | 1 + modules/home/programs/gpg/default.nix | 38 +++++++++++++++++++++++ old/home/programs/gpg.nix | 17 ---------- 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 modules/home/programs/gpg/default.nix delete mode 100644 old/home/programs/gpg.nix diff --git a/homes/x86_64-linux/marley@nyx/default.nix b/homes/x86_64-linux/marley@nyx/default.nix index 55502ff..8463115 100644 --- a/homes/x86_64-linux/marley@nyx/default.nix +++ b/homes/x86_64-linux/marley@nyx/default.nix @@ -27,6 +27,7 @@ in gh = enabled; git = enabled; glow = enabled; + gpg = enabled; journalctl = enabled; neo = enabled; systemctl = enabled; diff --git a/modules/home/programs/gpg/default.nix b/modules/home/programs/gpg/default.nix new file mode 100644 index 0000000..4295d26 --- /dev/null +++ b/modules/home/programs/gpg/default.nix @@ -0,0 +1,38 @@ +{ + 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; + }; + }; +} diff --git a/old/home/programs/gpg.nix b/old/home/programs/gpg.nix deleted file mode 100644 index 242863b..0000000 --- a/old/home/programs/gpg.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, ... }: -{ - programs.gpg = { - enable = true; - }; - - services.gpg-agent = rec { - enable = true; - - # TODO: Set this to pinentry-curses on non-GUI systems. - pinentryPackage = pkgs.pinentry-gtk2; - - # Don't ask for the password very often. - defaultCacheTtl = 60480000; - maxCacheTtl = defaultCacheTtl; - }; -}