Skip to content

Commit

Permalink
programs/gnupg: move agent.pinentryFlavor to the desktops
Browse files Browse the repository at this point in the history
This avoids evaluating all the desktop environments at this place.
  • Loading branch information
SuperSandro2000 committed Jan 14, 2024
1 parent 1de7c1d commit daa53d2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
19 changes: 2 additions & 17 deletions nixos/modules/programs/gnupg.nix
Expand Up @@ -10,22 +10,7 @@ let
mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
};

xserverCfg = config.services.xserver;

defaultPinentryFlavor =
if xserverCfg.desktopManager.lxqt.enable
|| xserverCfg.desktopManager.plasma5.enable
|| xserverCfg.desktopManager.deepin.enable then
"qt"
else if xserverCfg.desktopManager.xfce.enable then
"gtk2"
else if xserverCfg.enable || config.programs.sway.enable then
"gnome3"
else
"curses";

in

{

options.programs.gnupg = {
Expand Down Expand Up @@ -68,8 +53,8 @@ in
agent.pinentryFlavor = mkOption {
type = types.nullOr (types.enum pkgs.pinentry.possibleFlavors);
example = "gnome3";
default = defaultPinentryFlavor;
defaultText = literalMD ''matching the configured desktop environment'';
default = "curses";
defaultText = literalMD ''matching the configured desktop environment or curses'';
description = lib.mdDoc ''
Which pinentry interface to use. If not null, the path to the
pinentry binary will be set in /etc/gnupg/gpg-agent.conf.
Expand Down
5 changes: 5 additions & 0 deletions nixos/modules/programs/wayland/sway.nix
Expand Up @@ -152,6 +152,7 @@ in {
'';
}
];

environment = {
systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
# Needed for the default wallpaper:
Expand All @@ -166,8 +167,12 @@ in {
"sway/config".source = mkOptionDefault "${cfg.package}/etc/sway/config";
};
};

programs.gnupg.agent.pinentryFlavor = "gnome3";

# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
xdg.portal.config.sway.default = mkDefault [ "wlr" "gtk" ];

# To make a Sway session available if a display manager like SDDM is enabled:
services.xserver.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ]; }
(import ./wayland-session.nix { inherit lib pkgs; })
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/x11/desktop-managers/deepin.nix
Expand Up @@ -66,6 +66,7 @@ in
services.upower.enable = mkDefault config.powerManagement.enable;
networking.networkmanager.enable = mkDefault true;
programs.dconf.enable = mkDefault true;
programs.gnupg.agent.pinentryFlavor = "qt";

fonts.packages = with pkgs; [ noto-fonts ];
xdg.mime.enable = true;
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/services/x11/desktop-managers/lxqt.nix
Expand Up @@ -62,6 +62,8 @@ in
# Link some extra directories in /run/current-system/software/share
environment.pathsToLink = [ "/share" ];

programs.gnupg.agent.pinentryFlavor = "qt";

# virtual file systems support for PCManFM-QT
services.gvfs.enable = true;

Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/x11/desktop-managers/plasma5.nix
Expand Up @@ -331,6 +331,7 @@ in
serif = [ "Noto Serif" ];
};

programs.gnupg.agent.pinentryFlavor = "qt";
programs.ssh.askPassword = mkDefault "${pkgs.plasma5Packages.ksshaskpass.out}/bin/ksshaskpass";

# Enable helpful DBus services.
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/x11/desktop-managers/xfce.nix
Expand Up @@ -131,6 +131,7 @@ in
xfdesktop
] ++ optional cfg.enableScreensaver xfce4-screensaver) excludePackages;

programs.gnupg.agent.pinentryFlavor = "gtk2";
programs.xfconf.enable = true;
programs.thunar.enable = true;

Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/services/x11/xserver.nix
Expand Up @@ -749,6 +749,8 @@ in
boot.kernel.sysctl."fs.inotify.max_user_instances" = mkDefault 524288;
boot.kernel.sysctl."fs.inotify.max_user_watches" = mkDefault 524288;

programs.gnupg.agent.pinentryFlavor = "gnome3";

systemd.defaultUnit = mkIf cfg.autorun "graphical.target";

systemd.services.display-manager =
Expand Down

0 comments on commit daa53d2

Please sign in to comment.