···11{ config, lib, pkgs, ... }:
2233-with lib;
44-53let
44+ inherit (lib) mkRemovedOptionModule mkOption mkPackageOption types mkIf optionalString;
6576 cfg = config.programs.gnupg;
87···2625 "curses";
27262827in
2929-3028{
2929+ imports = [
3030+ (mkRemovedOptionModule [ "programs" "gnupg" "agent" "pinentryFlavor" ] "Use programs.gnupg.agent.pinentryPackage instead")
3131+ ];
31323233 options.programs.gnupg = {
3334 package = mkPackageOption pkgs "gnupg" { };
···6667 '';
6768 };
68696969- agent.pinentryFlavor = mkOption {
7070- type = types.nullOr (types.enum pkgs.pinentry.flavors);
7171- example = "gnome3";
7272- default = defaultPinentryFlavor;
7373- defaultText = literalMD ''matching the configured desktop environment'';
7070+ agent.pinentryPackage = mkOption {
7171+ type = types.nullOr types.package;
7272+ example = lib.literalMD "pkgs.pinentry-gnome3";
7373+ default = pkgs.pinentry-curses;
7474+ defaultText = lib.literalMD "matching the configured desktop environment or `pkgs.pinentry-curses`";
7475 description = lib.mdDoc ''
7575- Which pinentry interface to use. If not null, the path to the
7676- pinentry binary will be set in /etc/gnupg/gpg-agent.conf.
7777- If not set at all, it'll pick an appropriate flavor depending on the
7878- system configuration (qt flavor for lxqt and plasma5, gtk2 for xfce
7979- 4.12, gnome3 on all other systems with X enabled, ncurses otherwise).
7676+ Which pinentry package to use. The path to the mainProgram as defined in
7777+ the package's meta attriutes will be set in /etc/gnupg/gpg-agent.conf.
7878+ If not set by the user, it'll pick an appropriate flavor depending on the
7979+ system configuration (qt flavor for lxqt and plasma5, gtk2 for xfce,
8080+ gnome3 on all other systems with X enabled, curses otherwise).
8081 '';
8182 };
8283···102103 };
103104104105 config = mkIf cfg.agent.enable {
105105- programs.gnupg.agent.settings = {
106106- pinentry-program = lib.mkIf (cfg.agent.pinentryFlavor != null)
107107- "${pkgs.pinentry.${cfg.agent.pinentryFlavor}}/bin/pinentry";
106106+ programs.gnupg.agent.settings = mkIf (cfg.agent.pinentryPackage != null) {
107107+ pinentry-program = lib.getExe cfg.agent.pinentryPackage;
108108 };
109109110110 environment.etc."gnupg/gpg-agent.conf".source =
···207207 wantedBy = [ "sockets.target" ];
208208 };
209209210210- services.dbus.packages = mkIf (cfg.agent.pinentryFlavor == "gnome3") [ pkgs.gcr ];
210210+ services.dbus.packages = mkIf (lib.elem "gnome3" (cfg.agent.pinentryPackage.flavors or [])) [ pkgs.gcr ];
211211212212- environment.systemPackages = with pkgs; [ cfg.package ];
212212+ environment.systemPackages = [ cfg.package ];
213213214214 environment.interactiveShellInit = ''
215215 # Bind gpg-agent to this TTY if gpg commands are used.
···230230 '';
231231232232 assertions = [
233233- { assertion = cfg.agent.enableSSHSupport -> !config.programs.ssh.startAgent;
233233+ {
234234+ assertion = cfg.agent.enableSSHSupport -> !config.programs.ssh.startAgent;
234235 message = "You can't use ssh-agent and GnuPG agent with SSH support enabled at the same time!";
235236 }
236237 ];
237238 };
238238-239239- # uses attributes of the linked package
240240- meta.buildDocsInSandbox = false;
241239}
+5
nixos/modules/programs/wayland/sway.nix
···152152 '';
153153 }
154154 ];
155155+155156 environment = {
156157 systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
157158 # Needed for the default wallpaper:
···166167 "sway/config".source = mkOptionDefault "${cfg.package}/etc/sway/config";
167168 };
168169 };
170170+171171+ programs.gnupg.agent.pinentryPackage = lib.mkDefault pkgs.pinentry-gnome3;
172172+169173 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
170174 xdg.portal.config.sway.default = mkDefault [ "wlr" "gtk" ];
175175+171176 # To make a Sway session available if a display manager like SDDM is enabled:
172177 services.xserver.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ]; }
173178 (import ./wayland-session.nix { inherit lib pkgs; })
+2-10
nixos/modules/services/security/yubikey-agent.nix
···6677let
88 cfg = config.services.yubikey-agent;
99-1010- # reuse the pinentryFlavor option from the gnupg module
1111- pinentryFlavor = config.programs.gnupg.agent.pinentryFlavor;
129in
1310{
1411 ###### interface
···4138 # This overrides the systemd user unit shipped with the
4239 # yubikey-agent package
4340 systemd.user.services.yubikey-agent = mkIf (pinentryFlavor != null) {
4444- path = [ pkgs.pinentry.${pinentryFlavor} ];
4545- wantedBy = [
4646- (if pinentryFlavor == "tty" || pinentryFlavor == "curses" then
4747- "default.target"
4848- else
4949- "graphical-session.target")
5050- ];
4141+ path = [ config.programs.gnupg.agent.pinentryPackage ];
4242+ wantedBy = [ "default.target" ];
5143 };
52445345 # Yubikey-agent expects pcsd to be running in order to function.
···6262 # Link some extra directories in /run/current-system/software/share
6363 environment.pathsToLink = [ "/share" ];
64646565+ programs.gnupg.agent.pinentryPackage = pkgs.pinentry-qt;
6666+6567 # virtual file systems support for PCManFM-QT
6668 services.gvfs.enable = true;
6769