Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ fetchurl, mkDerivation, fetchpatch, stdenv, lib, pkg-config, autoreconfHook, wrapGAppsHook 2, libgpg-error, libassuan, qtbase, wrapQtAppsHook 3, ncurses, gtk2, gcr 4, withLibsecret ? true, libsecret 5, enabledFlavors ? [ "curses" "tty" "gtk2" "emacs" ] 6 ++ lib.optionals stdenv.isLinux [ "gnome3" ] 7 ++ lib.optionals (!stdenv.isDarwin) [ "qt" ] 8}: 9 10assert lib.isList enabledFlavors && enabledFlavors != []; 11 12let 13 pinentryMkDerivation = 14 if (builtins.elem "qt" enabledFlavors) 15 then mkDerivation 16 else stdenv.mkDerivation; 17 18 enableFeaturePinentry = f: 19 let 20 flag = flavorInfo.${f}.flag or null; 21 in 22 lib.optionalString (flag != null) 23 (lib.enableFeature (lib.elem f enabledFlavors) ("pinentry-" + flag)); 24 25 flavorInfo = { 26 curses = { bin = "curses"; flag = "curses"; buildInputs = [ ncurses ]; }; 27 tty = { bin = "tty"; flag = "tty"; }; 28 gtk2 = { bin = "gtk-2"; flag = "gtk2"; buildInputs = [ gtk2 ]; }; 29 gnome3 = { bin = "gnome3"; flag = "gnome3"; buildInputs = [ gcr ]; nativeBuildInputs = [ wrapGAppsHook ]; }; 30 qt = { bin = "qt"; flag = "qt"; buildInputs = [ qtbase ]; nativeBuildInputs = [ wrapQtAppsHook ]; }; 31 emacs = { bin = "emacs"; flag = "emacs"; buildInputs = []; }; 32 }; 33 34in 35 36pinentryMkDerivation rec { 37 pname = "pinentry"; 38 version = "1.2.1"; 39 40 src = fetchurl { 41 url = "mirror://gnupg/pinentry/${pname}-${version}.tar.bz2"; 42 sha256 = "sha256-RXoYXlqFI4+5RalV3GNSq5YtyLSHILYvyfpIx1QKQGc="; 43 }; 44 45 nativeBuildInputs = [ pkg-config autoreconfHook ] 46 ++ lib.concatMap(f: flavorInfo.${f}.nativeBuildInputs or []) enabledFlavors; 47 48 buildInputs = [ libgpg-error libassuan ] 49 ++ lib.optional withLibsecret libsecret 50 ++ lib.concatMap(f: flavorInfo.${f}.buildInputs or []) enabledFlavors; 51 52 dontWrapGApps = true; 53 dontWrapQtApps = true; 54 55 patches = [ 56 ./autoconf-ar.patch 57 ] ++ lib.optionals (lib.elem "gtk2" enabledFlavors) [ 58 (fetchpatch { 59 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"; 60 sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd"; 61 }) 62 ]; 63 64 configureFlags = [ 65 "--with-libgpg-error-prefix=${libgpg-error.dev}" 66 "--with-libassuan-prefix=${libassuan.dev}" 67 (lib.enableFeature withLibsecret "libsecret") 68 ] ++ (map enableFeaturePinentry (lib.attrNames flavorInfo)); 69 70 postInstall = 71 lib.concatStrings (lib.flip map enabledFlavors (f: 72 let 73 binary = "pinentry-" + flavorInfo.${f}.bin; 74 in '' 75 moveToOutput bin/${binary} ${placeholder f} 76 ln -sf ${placeholder f}/bin/${binary} ${placeholder f}/bin/pinentry 77 '' + lib.optionalString (f == "gnome3") '' 78 wrapGApp ${placeholder f}/bin/${binary} 79 '' + lib.optionalString (f == "qt") '' 80 wrapQtApp ${placeholder f}/bin/${binary} 81 '')) + '' 82 ln -sf ${placeholder (lib.head enabledFlavors)}/bin/pinentry-${flavorInfo.${lib.head enabledFlavors}.bin} $out/bin/pinentry 83 ''; 84 85 outputs = [ "out" ] ++ enabledFlavors; 86 87 passthru = { flavors = enabledFlavors; }; 88 89 meta = with lib; { 90 homepage = "http://gnupg.org/aegypten2/"; 91 description = "GnuPGs interface to passphrase input"; 92 license = licenses.gpl2Plus; 93 platforms = platforms.all; 94 longDescription = '' 95 Pinentry provides a console and (optional) GTK and Qt GUIs allowing users 96 to enter a passphrase when `gpg' or `gpg2' is run and needs it. 97 ''; 98 maintainers = with maintainers; [ ttuegel fpletz ]; 99 }; 100}