Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions nixos/modules/programs/gnupg.nix
Original file line number Diff line number Diff line change
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 @@ -66,16 +51,16 @@ in
};

agent.pinentryFlavor = mkOption {
type = types.nullOr (types.enum pkgs.pinentry.flavors);
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.
If not set at all, it'll pick an appropriate flavor depending on the
system configuration (qt flavor for lxqt and plasma5, gtk2 for xfce
4.12, gnome3 on all other systems with X enabled, ncurses otherwise).
system configuration (qt flavor for lxqt and plasma5, gtk2 for xfce,
gnome3 on all other systems with X enabled, curses otherwise).
'';
};

Expand All @@ -102,8 +87,7 @@ in

config = mkIf cfg.agent.enable {
programs.gnupg.agent.settings = {
pinentry-program = lib.mkIf (cfg.agent.pinentryFlavor != null)
"${pkgs.pinentry.${cfg.agent.pinentryFlavor}}/bin/pinentry";
pinentry-program = lib.mkIf (cfg.agent.pinentryFlavor != null) (lib.getExe pkgs."pinentry-${cfg.agent.pinentryFlavor}");
};

environment.etc."gnupg/gpg-agent.conf".source =
Expand Down
5 changes: 5 additions & 0 deletions nixos/modules/programs/wayland/sway.nix
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
6 changes: 5 additions & 1 deletion pkgs/tools/security/pinentry/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ pinentryMkDerivation rec {

outputs = [ "out" ] ++ enabledFlavors;

passthru = { flavors = enabledFlavors; };
passthru = {
flavors = enabledFlavors;
possibleFlavors = lib.attrNames flavorInfo;
};

meta = with lib; {
homepage = "http://gnupg.org/aegypten2/";
Expand All @@ -95,6 +98,7 @@ pinentryMkDerivation rec {
Pinentry provides a console and (optional) GTK and Qt GUIs allowing users
to enter a passphrase when `gpg' or `gpg2' is run and needs it.
'';
mainProgram = "pinentry";
maintainers = with maintainers; [ ttuegel fpletz ];
};
}
10 changes: 5 additions & 5 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12070,11 +12070,11 @@ with pkgs;

pinentry = libsForQt5.callPackage ../tools/security/pinentry { };

pinentry-curses = (lib.getOutput "curses" pinentry);
pinentry-emacs = (lib.getOutput "emacs" pinentry);
pinentry-gtk2 = (lib.getOutput "gtk2" pinentry);
pinentry-qt = (lib.getOutput "qt" pinentry);
pinentry-gnome = (lib.getOutput "gnome3" pinentry);
pinentry-curses = pinentry.override { enabledFlavors = [ "curses" ]; };
pinentry-emacs = pinentry.override { enabledFlavors = [ "emacs" ]; };
pinentry-gtk2 = pinentry.override { enabledFlavors = [ "gtk2" ]; };
pinentry-qt = pinentry.override { enabledFlavors = [ "qt" ]; };
pinentry-gnome3 = pinentry.override { enabledFlavors = [ "gnome3" ]; };

pinentry_mac = callPackage ../tools/security/pinentry/mac.nix {
inherit (darwin.apple_sdk.frameworks) Cocoa;
Expand Down