2021-02-05 17:12:51 +00:00
|
|
|
|
{ fetchurl, mkDerivation, fetchpatch, stdenv, lib, pkg-config, autoreconfHook, wrapGAppsHook
|
2021-10-08 15:17:17 +00:00
|
|
|
|
, libgpg-error, libassuan, qtbase, wrapQtAppsHook
|
2022-12-17 10:02:37 +00:00
|
|
|
|
, ncurses, gtk2, gcr
|
|
|
|
|
, withLibsecret ? true, libsecret
|
2021-08-18 13:19:15 +00:00
|
|
|
|
, enabledFlavors ? [ "curses" "tty" "gtk2" "emacs" ]
|
|
|
|
|
++ lib.optionals stdenv.isLinux [ "gnome3" ]
|
2022-01-13 20:06:32 +00:00
|
|
|
|
++ lib.optionals (!stdenv.isDarwin) [ "qt" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
|
}:
|
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
|
assert lib.isList enabledFlavors && enabledFlavors != [];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
pinentryMkDerivation =
|
|
|
|
|
if (builtins.elem "qt" enabledFlavors)
|
|
|
|
|
then mkDerivation
|
|
|
|
|
else stdenv.mkDerivation;
|
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
|
enableFeaturePinentry = f:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
let
|
|
|
|
|
flag = flavorInfo.${f}.flag or null;
|
|
|
|
|
in
|
2022-12-17 10:02:37 +00:00
|
|
|
|
lib.optionalString (flag != null)
|
|
|
|
|
(lib.enableFeature (lib.elem f enabledFlavors) ("pinentry-" + flag));
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
flavorInfo = {
|
|
|
|
|
curses = { bin = "curses"; flag = "curses"; buildInputs = [ ncurses ]; };
|
|
|
|
|
tty = { bin = "tty"; flag = "tty"; };
|
|
|
|
|
gtk2 = { bin = "gtk-2"; flag = "gtk2"; buildInputs = [ gtk2 ]; };
|
|
|
|
|
gnome3 = { bin = "gnome3"; flag = "gnome3"; buildInputs = [ gcr ]; nativeBuildInputs = [ wrapGAppsHook ]; };
|
|
|
|
|
qt = { bin = "qt"; flag = "qt"; buildInputs = [ qtbase ]; nativeBuildInputs = [ wrapQtAppsHook ]; };
|
|
|
|
|
emacs = { bin = "emacs"; flag = "emacs"; buildInputs = []; };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
pinentryMkDerivation rec {
|
|
|
|
|
pname = "pinentry";
|
2022-12-17 10:02:37 +00:00
|
|
|
|
version = "1.2.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
|
url = "mirror://gnupg/pinentry/${pname}-${version}.tar.bz2";
|
2022-12-17 10:02:37 +00:00
|
|
|
|
sha256 = "sha256-RXoYXlqFI4+5RalV3GNSq5YtyLSHILYvyfpIx1QKQGc=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
nativeBuildInputs = [ pkg-config autoreconfHook ]
|
2022-12-17 10:02:37 +00:00
|
|
|
|
++ lib.concatMap(f: flavorInfo.${f}.nativeBuildInputs or []) enabledFlavors;
|
|
|
|
|
|
|
|
|
|
buildInputs = [ libgpg-error libassuan ]
|
|
|
|
|
++ lib.optional withLibsecret libsecret
|
|
|
|
|
++ lib.concatMap(f: flavorInfo.${f}.buildInputs or []) enabledFlavors;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
dontWrapGApps = true;
|
|
|
|
|
dontWrapQtApps = true;
|
|
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
|
./autoconf-ar.patch
|
2022-12-17 10:02:37 +00:00
|
|
|
|
] ++ lib.optionals (lib.elem "gtk2" enabledFlavors) [
|
2020-04-24 23:36:52 +00:00
|
|
|
|
(fetchpatch {
|
|
|
|
|
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";
|
|
|
|
|
sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd";
|
|
|
|
|
})
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
configureFlags = [
|
2023-04-29 16:46:19 +00:00
|
|
|
|
"--with-libgpg-error-prefix=${libgpg-error.dev}"
|
|
|
|
|
"--with-libassuan-prefix=${libassuan.dev}"
|
2022-12-17 10:02:37 +00:00
|
|
|
|
(lib.enableFeature withLibsecret "libsecret")
|
|
|
|
|
] ++ (map enableFeaturePinentry (lib.attrNames flavorInfo));
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
postInstall =
|
2022-12-17 10:02:37 +00:00
|
|
|
|
lib.concatStrings (lib.flip map enabledFlavors (f:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
let
|
|
|
|
|
binary = "pinentry-" + flavorInfo.${f}.bin;
|
|
|
|
|
in ''
|
|
|
|
|
moveToOutput bin/${binary} ${placeholder f}
|
|
|
|
|
ln -sf ${placeholder f}/bin/${binary} ${placeholder f}/bin/pinentry
|
2022-12-17 10:02:37 +00:00
|
|
|
|
'' + lib.optionalString (f == "gnome3") ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
wrapGApp ${placeholder f}/bin/${binary}
|
2022-12-17 10:02:37 +00:00
|
|
|
|
'' + lib.optionalString (f == "qt") ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
wrapQtApp ${placeholder f}/bin/${binary}
|
|
|
|
|
'')) + ''
|
2022-12-17 10:02:37 +00:00
|
|
|
|
ln -sf ${placeholder (lib.head enabledFlavors)}/bin/pinentry-${flavorInfo.${lib.head enabledFlavors}.bin} $out/bin/pinentry
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
outputs = [ "out" ] ++ enabledFlavors;
|
|
|
|
|
|
|
|
|
|
passthru = { flavors = enabledFlavors; };
|
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
homepage = "http://gnupg.org/aegypten2/";
|
|
|
|
|
description = "GnuPG’s interface to passphrase input";
|
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
|
platforms = platforms.all;
|
|
|
|
|
longDescription = ''
|
|
|
|
|
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.
|
|
|
|
|
'';
|
|
|
|
|
maintainers = with maintainers; [ ttuegel fpletz ];
|
|
|
|
|
};
|
|
|
|
|
}
|