feat(home): Add pinentry to theme module

This commit is contained in:
punkfairie 2024-11-16 19:12:51 -08:00
parent ab9fef99f7
commit 17113e608c
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696
3 changed files with 42 additions and 27 deletions

View file

@ -2,6 +2,7 @@
lib, lib,
namespace, namespace,
config, config,
pkgs,
... ...
}: }:
let let
@ -9,6 +10,7 @@ let
types types
mkOption mkOption
literalMD literalMD
mkMerge
mkIf mkIf
mkDefault mkDefault
; ;
@ -102,9 +104,17 @@ in
default = null; default = null;
description = "The icon theme to use."; 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) { config = mkMerge [
# icons
(mkIf (cfg.icons != null) {
gtk = mkIf config.gtk.enable (mkDefault { gtk = mkIf config.gtk.enable (mkDefault {
iconTheme = { iconTheme = {
inherit (cfg.icons) name; inherit (cfg.icons) name;
@ -118,5 +128,21 @@ in
package = mkIf (cfg.icons.package != null) cfg.package; 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;
});
}
];
} }

View file

@ -2,12 +2,11 @@
lib, lib,
config, config,
namespace, namespace,
pkgs,
... ...
}: }:
let let
inherit (lib) mkIf; inherit (lib) mkIf;
inherit (lib.${namespace}) mkEnableModule isDesktop; inherit (lib.${namespace}) mkEnableModule;
cfg = config.${namespace}.programs.gpg; cfg = config.${namespace}.programs.gpg;
in in
@ -15,12 +14,6 @@ in
options = mkEnableModule "programs.gpg"; options = mkEnableModule "programs.gpg";
config = mkIf cfg.enable { 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 = { programs.gpg = {
enable = true; enable = true;
}; };
@ -28,8 +21,6 @@ in
services.gpg-agent = rec { services.gpg-agent = rec {
enable = true; enable = true;
pinentryPackage = if isDesktop then pkgs.pinentry-gtk2 else pkgs.pinentry-curses;
# Don't ask for the password very often. # Don't ask for the password very often.
defaultCacheTtl = 60480000; defaultCacheTtl = 60480000;
maxCacheTtl = defaultCacheTtl; maxCacheTtl = defaultCacheTtl;

View file

@ -1,10 +1,8 @@
{ pkgs, ... }: { _ }:
{ {
programs.rbw = { programs.rbw = {
enable = true; enable = true;
settings.email = "bitwarden@punkfairie.net"; settings.email = "bitwarden@punkfairie.net";
# TODO: set this globally?
settings.pinentry = pkgs.pinentry-gtk2;
}; };
} }