nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

pinentry: build with multiple outputs in single drv

Co-authored-by: Florian Klink <flokli@flokli.de>
Co-authored-by: worldofpeace <worldofpeace@protonmail.ch>

authored by

Franz Pletz
Florian Klink
worldofpeace
and committed by
worldofpeace
cb0adc11 12441bdf

+74 -61
-1
nixos/modules/config/no-x-libs.nix
··· 34 34 networkmanager-openvpn = super.networkmanager-openvpn.override { withGnome = false; }; 35 35 networkmanager-vpnc = super.networkmanager-vpnc.override { withGnome = false; }; 36 36 networkmanager-iodine = super.networkmanager-iodine.override { withGnome = false; }; 37 - pinentry = super.pinentry.override { gtk2 = null; gcr = null; qt4 = null; qt5 = null; }; 38 37 gobject-introspection = super.gobject-introspection.override { x11Support = false; }; 39 38 })); 40 39 };
+68 -35
pkgs/tools/security/pinentry/default.nix
··· 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" ] 6 6 }: 7 7 8 - assert qt5 != null -> qt4 == null; 9 - assert qt4 != null -> qt5 == null; 8 + with stdenv.lib; 9 + 10 + assert isList enabledFlavors && enabledFlavors != []; 10 11 11 12 let 12 - mkDerivation = 13 - if qt5 != null 14 - then qt5.mkDerivation 13 + pinentryMkDerivation = 14 + if (builtins.elem "qt" enabledFlavors) 15 + then mkDerivation 15 16 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 + 16 40 in 17 41 18 - mkDerivation rec { 19 - name = "pinentry-1.1.0"; 42 + pinentryMkDerivation rec { 43 + pname = "pinentry"; 44 + version = "1.1.0"; 20 45 21 46 src = fetchurl { 22 - url = "mirror://gnupg/pinentry/${name}.tar.bz2"; 47 + url = "mirror://gnupg/pinentry/${pname}-${version}.tar.bz2"; 23 48 sha256 = "0w35ypl960pczg5kp6km3dyr000m1hf0vpwwlh72jjkjza36c1v8"; 24 49 }; 25 50 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; 30 55 31 - prePatch = '' 32 - substituteInPlace pinentry/pinentry-curses.c --replace ncursesw ncurses 33 - ''; 56 + dontWrapGApps = true; 57 + dontWrapQtApps = true; 34 58 35 59 patches = [ 36 60 ./autoconf-ar.patch 37 - ] ++ lib.optionals (gtk2 != null) [ 61 + ] ++ optionals (elem "gtk2" enabledFlavors) [ 38 62 (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"; 41 64 sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd"; 42 65 }) 43 66 ]; 44 67 45 68 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") 69 + (mkWith (libcap != null) "libcap") 70 + (mkEnable (libsecret != null) "libsecret") 71 + ] ++ (map mkEnablePinentry (attrNames flavorInfo)); 54 72 55 - "--with-libassuan-prefix=${libassuan.dev}" 56 - "--with-libgpg-error-prefix=${libgpgerror.dev}" 57 - ]; 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; }; 58 91 59 92 meta = with stdenv.lib; { 60 93 homepage = http://gnupg.org/aegypten2/; ··· 98 65 Pinentry provides a console and (optional) GTK and Qt GUIs allowing users 99 66 to enter a passphrase when `gpg' or `gpg2' is run and needs it. 100 67 ''; 101 - maintainers = [ maintainers.ttuegel ]; 68 + maintainers = with maintainers; [ ttuegel fpletz ]; 102 69 }; 103 70 }
+6 -25
pkgs/top-level/all-packages.nix
··· 5521 5521 5522 5522 phodav = callPackage ../tools/networking/phodav { }; 5523 5523 5524 - pinentry = callPackage ../tools/security/pinentry { 5524 + pinentry = libsForQt5.callPackage ../tools/security/pinentry { 5525 5525 libcap = if stdenv.isDarwin then null else libcap; 5526 - gcr = null; 5527 - qt4 = null; 5528 - qt5 = null; 5529 5526 }; 5530 5527 5531 - pinentry_ncurses = res.pinentry.override { 5532 - gtk2 = null; 5533 - }; 5534 - 5535 - pinentry_emacs = res.pinentry.override { 5536 - enableEmacs = true; 5537 - }; 5538 - 5539 - pinentry_gnome = res.pinentry.override { 5540 - inherit gcr; 5541 - }; 5542 - 5543 - pinentry_qt4 = res.pinentry.override { 5544 - gtk2 = null; 5545 - inherit qt4; 5546 - }; 5547 - 5548 - pinentry_qt5 = res.pinentry.override { 5549 - gtk2 = null; 5550 - inherit qt5; 5551 - }; 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); 5552 5533 5553 5534 pinentry_mac = callPackage ../tools/security/pinentry/mac.nix { 5554 5535 inherit (darwin.apple_sdk.frameworks) Cocoa;