git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #71095 from flokli/pinentry-cleanup

Split pinentry flavors and enable udisks2 on install media again

commit823da4d492b8b4ad46bf812db8421d99ff17a8fc authorworldofpeace <worldofpeace@protonmail.ch> dateThu 17 Oct 2019, 00:24 (7 years ago) parentb75c8eee397b94
15 files changed+142−89
nixos/doc/manual/release-notes/rl-2003.xml+8−1 nixos/modules/config/no-x-libs.nix−1 nixos/modules/installer/tools/tools.nix+5−1 nixos/modules/profiles/installation-device.nix−3 nixos/modules/programs/gnupg.nix+38−1 nixos/modules/services/hardware/udisks2.nix+1−4 nixos/tests/installer.nix−4 nixos/tests/os-prober.nix+1−2 pkgs/development/libraries/gcr/default.nix+1−5 pkgs/tools/security/gnupg/20.nix+1−1 pkgs/tools/security/gnupg/22.nix+1−1 pkgs/tools/security/kwalletcli/default.nix+2−2 pkgs/tools/security/pinentry/default.nix+69−36 pkgs/top-level/aliases.nix+5 pkgs/top-level/all-packages.nix+10−27
nixos/doc/manual/release-notes/rl-2003.xml+8−1
@@ -85,7 +85,14 @@
8585
8686 <itemizedlist>
8787 <listitem>
88− <para />
88+ <para>
89+ GnuPG is now built without support for a graphical passphrase entry
90+ by default. Please enable the <literal>gpg-agent</literal> user service
91+ via the NixOS option <literal>programs.gnupg.agent.enable</literal>.
92+ Note that upstream recommends using <literal>gpg-agent</literal> and
93+ will spawn a <literal>gpg-agent</literal> on the first invocation of
94+ GnuPG anyway.
95+ </para>
8996 </listitem>
9097 </itemizedlist>
9198 </section>
nixos/modules/config/no-x-libs.nix−1
@@ -34,7 +34,6 @@ with lib;
3434 networkmanager-openvpn = super.networkmanager-openvpn.override { withGnome = false; };
3535 networkmanager-vpnc = super.networkmanager-vpnc.override { withGnome = false; };
3636 networkmanager-iodine = super.networkmanager-iodine.override { withGnome = false; };
37− pinentry = super.pinentry.override { gtk2 = null; gcr = null; qt4 = null; qt5 = null; };
3837 gobject-introspection = super.gobject-introspection.override { x11Support = false; };
3938 }));
4039 };
nixos/modules/installer/tools/tools.nix+5−1
@@ -120,7 +120,11 @@ in
120120 # Some programs need SUID wrappers, can be configured further or are
121121 # started in user sessions.
122122 # programs.mtr.enable = true;
123− # programs.gnupg.agent = { enable = true; enableSSHSupport = true; };
123+ # programs.gnupg.agent = {
124+ # enable = true;
125+ # enableSSHSupport = true;
126+ # flavour = "gnome3";
127+ # };
124128
125129 # List services that you want to enable:
126130
nixos/modules/profiles/installation-device.nix−3
@@ -31,9 +31,6 @@ with lib;
3131 # Let the user play Rogue on TTY 8 during the installation.
3232 #services.rogue.enable = true;
3333
34− # Disable some other stuff we don't need.
35− services.udisks2.enable = mkDefault false;
36−
3734 # Use less privileged nixos user
3835 users.users.nixos = {
3936 isNormalUser = true;
nixos/modules/programs/gnupg.nix+38−1
@@ -6,6 +6,19 @@ let
66
77 cfg = config.programs.gnupg;
88
9+ xserverCfg = config.services.xserver;
10+
11+ defaultPinentryFlavor =
12+ if xserverCfg.desktopManager.lxqt.enable
13+ || xserverCfg.desktopManager.plasma5.enable then
14+ "qt"
15+ else if xserverCfg.desktopManager.xfce.enable then
16+ "gtk2"
17+ else if xserverCfg.enable then
18+ "gnome3"
19+ else
20+ null;
21+
922in
1023
1124{
@@ -54,6 +67,20 @@ in
5467 '';
5568 };
5669
70+ agent.pinentryFlavor = mkOption {
71+ type = types.nullOr (types.enum pkgs.pinentry.flavors);
72+ example = "gnome3";
73+ description = ''
74+ Which pinentry interface to use. If not null, the path to the
75+ pinentry binary will be passed to gpg-agent via commandline and
76+ thus overrides the pinentry option in gpg-agent.conf in the user's
77+ home directory.
78+ If not set at all, it'll pick an appropriate flavor depending on the
79+ system configuration (qt flavor for lxqt and plasma5, gtk2 for xfce
80+ 4.12, gnome3 on all other systems with X enabled, ncurses otherwise).
81+ '';
82+ };
83+
5784 dirmngr.enable = mkOption {
5885 type = types.bool;
5986 default = false;
@@ -64,6 +91,16 @@ in
6491 };
6592
6693 config = mkIf cfg.agent.enable {
94+ programs.gnupg.agent.pinentryFlavor = mkDefault defaultPinentryFlavor;
95+
96+ # This overrides the systemd user unit shipped with the gnupg package
97+ systemd.user.services.gpg-agent = mkIf (cfg.agent.pinentryFlavor != null) {
98+ serviceConfig.ExecStart = [ "" ''
99+ ${pkgs.gnupg}/bin/gpg-agent --supervised \
100+ --pinentry-program ${pkgs.pinentry.${cfg.agent.pinentryFlavor}}/bin/pinentry
101+ '' ];
102+ };
103+
67104 systemd.user.sockets.gpg-agent = {
68105 wantedBy = [ "sockets.target" ];
69106 };
@@ -83,7 +120,7 @@ in
83120 systemd.user.sockets.dirmngr = mkIf cfg.dirmngr.enable {
84121 wantedBy = [ "sockets.target" ];
85122 };
86−
123+
87124 environment.systemPackages = with pkgs; [ cfg.package ];
88125 systemd.packages = [ cfg.package ];
89126
nixos/modules/services/hardware/udisks2.nix+1−4
@@ -34,10 +34,7 @@ with lib;
3434
3535 services.dbus.packages = [ pkgs.udisks2 ];
3636
37− system.activationScripts.udisks2 =
38− ''
39− mkdir -m 0755 -p /var/lib/udisks2
40− '';
37+ systemd.tmpfiles.rules = [ "d /var/lib/udisks2 0755 root root -" ];
4138
4239 services.udev.packages = [ pkgs.udisks2 ];
4340
nixos/tests/installer.nix−4
@@ -54,8 +54,6 @@ let
5454
5555 hardware.enableAllFirmware = lib.mkForce false;
5656
57− services.udisks2.enable = lib.mkDefault false;
58−
5957 ${replaceChars ["\n"] ["\n "] extraConfig}
6058 }
6159 '';
@@ -295,8 +293,6 @@ let
295293 ++ optional (bootLoader == "grub" && grubVersion == 1) pkgs.grub
296294 ++ optionals (bootLoader == "grub" && grubVersion == 2) [ pkgs.grub2 pkgs.grub2_efi ];
297295
298− services.udisks2.enable = mkDefault false;
299−
300296 nix.binaryCaches = mkForce [ ];
301297 nix.extraOptions =
302298 ''
nixos/tests/os-prober.nix+1−2
@@ -51,12 +51,11 @@ let
5151 hashed-mirrors =
5252 connect-timeout = 1
5353 '';
54− services.udisks2.enable = lib.mkForce false;
5554 };
5655 # /etc/nixos/configuration.nix for the vm
5756 configFile = pkgs.writeText "configuration.nix" ''
5857 {config, pkgs, ...}: ({
59− imports =
58+ imports =
6059 [ ./hardware-configuration.nix
6160 <nixpkgs/nixos/modules/testing/test-instrumentation.nix>
6261 ];
pkgs/development/libraries/gcr/default.nix+1−5
@@ -24,11 +24,7 @@ stdenv.mkDerivation rec {
2424
2525 nativeBuildInputs = [ pkgconfig gettext gobject-introspection libxslt makeWrapper vala ];
2626
27− buildInputs = let
28− gpg = gnupg.override { guiSupport = false; }; # prevent build cycle with pinentry_gnome
29− in [
30− gpg libgcrypt libtasn1 dbus-glib pango gdk-pixbuf atk
31− ];
27+ buildInputs = [ gnupg libgcrypt libtasn1 dbus-glib pango gdk-pixbuf atk ];
3228
3329 propagatedBuildInputs = [ glib gtk3 p11-kit ];
3430
pkgs/tools/security/gnupg/20.nix+1−1
@@ -3,7 +3,7 @@
33
44# Each of the dependencies below are optional.
55# Gnupg can be built without them at the cost of reduced functionality.
6−, pinentry ? null, guiSupport ? true
6+, pinentry ? null, guiSupport ? false
77, openldap ? null, bzip2 ? null, libusb ? null, curl ? null
88}:
99
pkgs/tools/security/gnupg/22.nix+1−1
@@ -4,7 +4,7 @@
44
55# Each of the dependencies below are optional.
66# Gnupg can be built without them at the cost of reduced functionality.
7−, pinentry ? null, guiSupport ? true
7+, pinentry ? null, guiSupport ? false
88, adns ? null, gnutls ? null, libusb ? null, openldap ? null
99, readline ? null, zlib ? null, bzip2 ? null
1010}:
pkgs/tools/security/kwalletcli/default.nix+2−2
@@ -1,5 +1,5 @@
11{ mkDerivation, fetchFromGitHub, lib, makeWrapper, pkgconfig
2−, kcoreaddons, ki18n, kwallet, mksh, pinentry_qt5 }:
2+, kcoreaddons, ki18n, kwallet, mksh, pinentry-qt }:
33
44mkDerivation rec {
55 pname = "kwalletcli";
@@ -36,7 +36,7 @@ mkDerivation rec {
3636
3737 postInstall = ''
3838 wrapProgram $out/bin/pinentry-kwallet \
39− --prefix PATH : $out/bin:${lib.makeBinPath [ pinentry_qt5 ]} \
39+ --prefix PATH : $out/bin:${lib.makeBinPath [ pinentry-qt ]} \
4040 --set-default PINENTRY pinentry-qt
4141 '';
4242
pkgs/tools/security/pinentry/default.nix+69−36
@@ -1,60 +1,93 @@
1−{ fetchurl, fetchpatch, stdenv, lib, pkgconfig, autoreconfHook
2−, libgpgerror, libassuan
3−, libcap ? null, libsecret ? null, ncurses ? null, gtk2 ? null, gcr ? null
4−, qt4 ? null, qt5 ? null
5−, enableEmacs ? false
1+{ fetchurl, mkDerivation, fetchpatch, stdenv, lib, pkgconfig, autoreconfHook, wrapGAppsHook
2+, libgpgerror, libassuan, qtbase, wrapQtAppsHook
3+, ncurses, gtk2, gcr
4+, libcap ? null, libsecret ? null
5+, enabledFlavors ? [ "curses" "tty" "gtk2" "qt" "gnome3" "emacs" ]
66}:
77
8−assert qt5 != null -> qt4 == null;
9−assert qt4 != null -> qt5 == null;
8+with stdenv.lib;
9+
10+assert isList enabledFlavors && enabledFlavors != [];
1011
1112let
12− mkDerivation =
13− if qt5 != null
14− then qt5.mkDerivation
13+ pinentryMkDerivation =
14+ if (builtins.elem "qt" enabledFlavors)
15+ then mkDerivation
1516 else stdenv.mkDerivation;
17+
18+ mkFlag = pfxTrue: pfxFalse: cond: name:
19+ "--${if cond then pfxTrue else pfxFalse}-${name}";
20+ mkEnable = mkFlag "enable" "disable";
21+ mkWith = mkFlag "with" "without";
22+
23+ mkEnablePinentry = f:
24+ let
25+ info = flavorInfo.${f};
26+ flag = flavorInfo.${f}.flag or null;
27+ in
28+ optionalString (flag != null)
29+ (mkEnable (elem f enabledFlavors) ("pinentry-" + flag));
30+
31+ flavorInfo = {
32+ curses = { bin = "curses"; flag = "curses"; buildInputs = [ ncurses ]; };
33+ tty = { bin = "tty"; flag = "tty"; };
34+ gtk2 = { bin = "gtk-2"; flag = "gtk2"; buildInputs = [ gtk2 ]; };
35+ gnome3 = { bin = "gnome3"; flag = "gnome3"; buildInputs = [ gcr ]; nativeBuildInputs = [ wrapGAppsHook ]; };
36+ qt = { bin = "qt"; flag = "qt"; buildInputs = [ qtbase ]; nativeBuildInputs = [ wrapQtAppsHook ]; };
37+ emacs = { bin = "emacs"; flag = "emacs"; buildInputs = []; };
38+ };
39+
1640in
1741
18−mkDerivation rec {
19− name = "pinentry-1.1.0";
42+pinentryMkDerivation rec {
43+ pname = "pinentry";
44+ version = "1.1.0";
2045
2146 src = fetchurl {
22− url = "mirror://gnupg/pinentry/${name}.tar.bz2";
47+ url = "mirror://gnupg/pinentry/${pname}-${version}.tar.bz2";
2348 sha256 = "0w35ypl960pczg5kp6km3dyr000m1hf0vpwwlh72jjkjza36c1v8";
2449 };
2550
26− nativeBuildInputs = [ pkgconfig autoreconfHook ];
27− buildInputs =
28− [ libgpgerror libassuan libcap libsecret gtk2 gcr ncurses qt4 ]
29− ++ stdenv.lib.optional (qt5 != null) qt5.qtbase;
51+ nativeBuildInputs = [ pkgconfig autoreconfHook ]
52+ ++ concatMap(f: flavorInfo.${f}.nativeBuildInputs or []) enabledFlavors;
53+ buildInputs = [ libgpgerror libassuan libcap libsecret ]
54+ ++ concatMap(f: flavorInfo.${f}.buildInputs or []) enabledFlavors;
3055
31− prePatch = ''
32− substituteInPlace pinentry/pinentry-curses.c --replace ncursesw ncurses
33− '';
56+ dontWrapGApps = true;
57+ dontWrapQtApps = true;
3458
3559 patches = [
3660 ./autoconf-ar.patch
37− ] ++ lib.optionals (gtk2 != null) [
61+ ] ++ optionals (elem "gtk2" enabledFlavors) [
3862 (fetchpatch {
39− url = "https://salsa.debian.org/debian/pinentry/raw/debian/1.1.0-1/debian/patches/"
40− + "0007-gtk2-When-X11-input-grabbing-fails-try-again-over-0..patch";
63+ url = "https://salsa.debian.org/debian/pinentry/raw/debian/1.1.0-1/debian/patches/0007-gtk2-When-X11-input-grabbing-fails-try-again-over-0..patch";
4164 sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd";
4265 })
4366 ];
4467
4568 configureFlags = [
46− (stdenv.lib.withFeature (libcap != null) "libcap")
47− (stdenv.lib.enableFeature (libsecret != null) "libsecret")
48− (stdenv.lib.enableFeature (ncurses != null) "pinentry-curses")
49− (stdenv.lib.enableFeature true "pinentry-tty")
50− (stdenv.lib.enableFeature enableEmacs "pinentry-emacs")
51− (stdenv.lib.enableFeature (gtk2 != null) "pinentry-gtk2")
52− (stdenv.lib.enableFeature (gcr != null) "pinentry-gnome3")
53− (stdenv.lib.enableFeature (qt4 != null || qt5 != null) "pinentry-qt")
54−
55− "--with-libassuan-prefix=${libassuan.dev}"
56− "--with-libgpg-error-prefix=${libgpgerror.dev}"
57− ];
69+ (mkWith (libcap != null) "libcap")
70+ (mkEnable (libsecret != null) "libsecret")
71+ ] ++ (map mkEnablePinentry (attrNames flavorInfo));
72+
73+ postInstall =
74+ concatStrings (flip map enabledFlavors (f:
75+ let
76+ binary = "pinentry-" + flavorInfo.${f}.bin;
77+ in ''
78+ moveToOutput bin/${binary} ${placeholder f}
79+ ln -sf ${placeholder f}/bin/${binary} ${placeholder f}/bin/pinentry
80+ '' + optionalString (f == "gnome3") ''
81+ wrapGApp ${placeholder f}/bin/${binary}
82+ '' + optionalString (f == "qt") ''
83+ wrapQtApp ${placeholder f}/bin/${binary}
84+ '')) + ''
85+ ln -sf ${placeholder (head enabledFlavors)}/bin/pinentry-${flavorInfo.${head enabledFlavors}.bin} $out/bin/pinentry
86+ '';
87+
88+ outputs = [ "out" ] ++ enabledFlavors;
89+
90+ passthru = { flavors = enabledFlavors; };
5891
5992 meta = with stdenv.lib; {
6093 homepage = http://gnupg.org/aegypten2/;
@@ -65,6 +98,6 @@ mkDerivation rec {
6598 Pinentry provides a console and (optional) GTK and Qt GUIs allowing users
6699 to enter a passphrase when `gpg' or `gpg2' is run and needs it.
67100 '';
68− maintainers = [ maintainers.ttuegel ];
101+ maintainers = with maintainers; [ ttuegel fpletz ];
69102 };
70103}
pkgs/top-level/aliases.nix+5
@@ -290,6 +290,11 @@ mapAliases ({
290290 pg_hll = postgresqlPackages.pg_hll;
291291 pg_cron = postgresqlPackages.pg_cron;
292292 pg_topn = postgresqlPackages.pg_topn;
293+ pinentry_curses = pinentry-curses; # added 2019-10-14
294+ pinentry_emacs = pinentry-emacs; # added 2019-10-14
295+ pinentry_gtk2 = pinentry-gtk2; # added 2019-10-14
296+ pinentry_qt = pinentry-qt; # added 2019-10-14
297+ pinentry_gnome = pinentry-gnome; # added 2019-10-14
293298 postgis = postgresqlPackages.postgis;
294299 # end
295300 ppl-address-book = throw "deprecated in 2019-05-02: abandoned by upstream.";
pkgs/top-level/all-packages.nix+10−27
@@ -3497,10 +3497,12 @@ in
34973497 gnupg1compat = callPackage ../tools/security/gnupg/1compat.nix { };
34983498 gnupg1 = gnupg1compat; # use config.packageOverrides if you prefer original gnupg1
34993499 gnupg20 = callPackage ../tools/security/gnupg/20.nix {
3500− pinentry = if stdenv.isDarwin then pinentry_mac else pinentry;
3500+ guiSupport = stdenv.isDarwin;
3501+ pinentry = if stdenv.isDarwin then pinentry_mac else pinentry_gtk2;
35013502 };
35023503 gnupg22 = callPackage ../tools/security/gnupg/22.nix {
3503− pinentry = if stdenv.isDarwin then pinentry_mac else pinentry;
3504+ guiSupport = stdenv.isDarwin;
3505+ pinentry = if stdenv.isDarwin then pinentry_mac else pinentry_gtk2;
35043506 };
35053507 gnupg = gnupg22;
35063508
@@ -5519,34 +5521,15 @@ in
55195521
55205522 phodav = callPackage ../tools/networking/phodav { };
55215523
5522− pinentry = callPackage ../tools/security/pinentry {
5524+ pinentry = libsForQt5.callPackage ../tools/security/pinentry {
55235525 libcap = if stdenv.isDarwin then null else libcap;
5524− gcr = null;
5525− qt4 = null;
5526− qt5 = null;
5527− };
5528−
5529− pinentry_ncurses = res.pinentry.override {
5530− gtk2 = null;
55315526 };
55325527
5533− pinentry_emacs = res.pinentry.override {
5534− enableEmacs = true;
5535− };
5536−
5537− pinentry_gnome = res.pinentry.override {
5538− inherit gcr;
5539− };
5540−
5541− pinentry_qt4 = res.pinentry.override {
5542− gtk2 = null;
5543− inherit qt4;
5544− };
5545−
5546− pinentry_qt5 = res.pinentry.override {
5547− gtk2 = null;
5548− inherit qt5;
5549− };
5528+ pinentry-curses = (stdenv.lib.getOutput "curses" pinentry);
5529+ pinentry-emacs = (stdenv.lib.getOutput "emacs" pinentry);
5530+ pinentry-gtk2 = (stdenv.lib.getOutput "gtk2" pinentry);
5531+ pinentry-qt = (stdenv.lib.getOutput "qt" pinentry);
5532+ pinentry-gnome = (stdenv.lib.getOutput "gnome" pinentry);
55505533
55515534 pinentry_mac = callPackage ../tools/security/pinentry/mac.nix {
55525535 inherit (darwin.apple_sdk.frameworks) Cocoa;