From 17113e608cf7fd384a8b17c79fa1fbdca38b5b09 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sat, 16 Nov 2024 19:12:51 -0800 Subject: [PATCH] feat(home): Add pinentry to theme module --- modules/home/options/theme/default.nix | 54 +++++++++++++++++++------- modules/home/programs/gpg/default.nix | 11 +----- old/home/programs/rbw.nix | 4 +- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/modules/home/options/theme/default.nix b/modules/home/options/theme/default.nix index c785013..ba730f4 100644 --- a/modules/home/options/theme/default.nix +++ b/modules/home/options/theme/default.nix @@ -2,6 +2,7 @@ lib, namespace, config, + pkgs, ... }: let @@ -9,6 +10,7 @@ let types mkOption literalMD + mkMerge mkIf mkDefault ; @@ -102,21 +104,45 @@ in default = null; description = "The icon theme to use."; }; + + pinentry = mkOption { + type = with types; package; + default = pkgs.pinentry-gtk2; + description = "The pinentry package to use."; + }; }; - config = mkIf (cfg.icons != null) { - gtk = mkIf config.gtk.enable (mkDefault { - iconTheme = { - inherit (cfg.icons) name; - package = mkIf (cfg.icons.package != null) cfg.package; - }; - }); + config = mkMerge [ + # icons + (mkIf (cfg.icons != null) { + gtk = mkIf config.gtk.enable (mkDefault { + iconTheme = { + inherit (cfg.icons) name; + package = mkIf (cfg.icons.package != null) cfg.package; + }; + }); - services.dunst = mkIf config.services.dunst.enable (mkDefault { - iconTheme = { - inherit (cfg.icons) name; - package = mkIf (cfg.icons.package != null) cfg.package; - }; - }); - }; + services.dunst = mkIf config.services.dunst.enable (mkDefault { + iconTheme = { + inherit (cfg.icons) name; + package = mkIf (cfg.icons.package != null) cfg.package; + }; + }); + }) + + # pinentry + { + home.packages = [ + cfg.pinentry + ]; + + programs.rbw = mkIf config.programs.rbw.enable (mkDefault { + settings.pinentry = cfg.pinentry; + }); + + services.gpg-agent = mkIf config.services.gpg-agent.enable (mkDefault { + pinentryPackage = cfg.pinentry; + }); + } + ]; } diff --git a/modules/home/programs/gpg/default.nix b/modules/home/programs/gpg/default.nix index 4295d26..05003f3 100644 --- a/modules/home/programs/gpg/default.nix +++ b/modules/home/programs/gpg/default.nix @@ -2,12 +2,11 @@ lib, config, namespace, - pkgs, ... }: let inherit (lib) mkIf; - inherit (lib.${namespace}) mkEnableModule isDesktop; + inherit (lib.${namespace}) mkEnableModule; cfg = config.${namespace}.programs.gpg; in @@ -15,12 +14,6 @@ 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; }; @@ -28,8 +21,6 @@ in 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/rbw.nix b/old/home/programs/rbw.nix index 7e926cd..9541bdf 100644 --- a/old/home/programs/rbw.nix +++ b/old/home/programs/rbw.nix @@ -1,10 +1,8 @@ -{ pkgs, ... }: +{ _ }: { programs.rbw = { enable = true; settings.email = "bitwarden@punkfairie.net"; - # TODO: set this globally? - settings.pinentry = pkgs.pinentry-gtk2; }; }