@@ -1,93 +1,60 @@
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" ]
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
66}:
77
8−with stdenv.lib;
9−
10−assert isList enabledFlavors && enabledFlavors != [];
8+assert qt5 != null -> qt4 == null;
9+assert qt4 != null -> qt5 == null;
1110
1211let
13− pinentryMkDerivation =
14− if (builtins.elem "qt" enabledFlavors)
15− then mkDerivation
12+ mkDerivation =
13+ if qt5 != null
14+ then qt5.mkDerivation
1615 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−
4016in
4117
42−pinentryMkDerivation rec {
43− pname = "pinentry";
44− version = "1.1.0";
18+mkDerivation rec {
19+ name = "pinentry-1.1.0";
4520
4621 src = fetchurl {
47− url = "mirror://gnupg/pinentry/${pname}-${version}.tar.bz2";
22+ url = "mirror://gnupg/pinentry/${name}.tar.bz2";
4823 sha256 = "0w35ypl960pczg5kp6km3dyr000m1hf0vpwwlh72jjkjza36c1v8";
4924 };
5025
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;
26+ nativeBuildInputs = [ pkgconfig autoreconfHook ];
27+ buildInputs =
28+ [ libgpgerror libassuan libcap libsecret gtk2 gcr ncurses qt4 ]
29+ ++ stdenv.lib.optional (qt5 != null) qt5.qtbase;
5530
56− dontWrapGApps = true;
57− dontWrapQtApps = true;
31+ prePatch = ''
32+ substituteInPlace pinentry/pinentry-curses.c --replace ncursesw ncurses
33+ '';
5834
5935 patches = [
6036 ./autoconf-ar.patch
61− ] ++ optionals (elem "gtk2" enabledFlavors) [
37+ ] ++ lib.optionals (gtk2 != null) [
6238 (fetchpatch {
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";
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";
6441 sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd";
6542 })
6643 ];
6744
6845 configureFlags = [
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; };
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+ ];
9158
9259 meta = with stdenv.lib; {
9360 homepage = http://gnupg.org/aegypten2/;
@@ -98,6 +65,6 @@ pinentryMkDerivation rec {
9865 Pinentry provides a console and (optional) GTK and Qt GUIs allowing users
9966 to enter a passphrase when `gpg' or `gpg2' is run and needs it.
10067 '';
101− maintainers = with maintainers; [ ttuegel fpletz ];
68+ maintainers = [ maintainers.ttuegel ];
10269 };
10370}