nixpkgs/pkgs/tools/security/pinentry/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

99 lines
3.4 KiB
Nix
Raw Normal View History

2021-01-17 03:51:22 +00:00
{ fetchurl, mkDerivation, fetchpatch, stdenv, lib, pkg-config, autoreconfHook, wrapGAppsHook
, libgpg-error, libassuan, qtbase, wrapQtAppsHook
2022-11-14 11:53:16 +00:00
, ncurses, gtk2, gcr
, withLibsecret ? true, libsecret
, enabledFlavors ? [ "curses" "tty" "gtk2" "emacs" ]
2021-08-12 20:17:54 +00:00
++ lib.optionals stdenv.isLinux [ "gnome3" ]
++ lib.optionals (!stdenv.isDarwin) [ "qt" ]
2015-03-25 23:09:00 +00:00
}:
2022-12-05 01:42:22 +00:00
assert lib.isList enabledFlavors && enabledFlavors != [];
2019-07-24 16:26:16 +00:00
let
pinentryMkDerivation =
if (builtins.elem "qt" enabledFlavors)
then mkDerivation
2019-07-24 16:26:16 +00:00
else stdenv.mkDerivation;
enableFeaturePinentry = f:
let
flag = flavorInfo.${f}.flag or null;
in
2022-12-05 01:42:22 +00:00
lib.optionalString (flag != null)
(lib.enableFeature (lib.elem f enabledFlavors) ("pinentry-" + flag));
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 = []; };
};
2019-07-24 16:26:16 +00:00
in
pinentryMkDerivation rec {
pname = "pinentry";
2022-11-14 11:53:16 +00:00
version = "1.2.1";
src = fetchurl {
url = "mirror://gnupg/pinentry/${pname}-${version}.tar.bz2";
2022-11-14 11:53:16 +00:00
sha256 = "sha256-RXoYXlqFI4+5RalV3GNSq5YtyLSHILYvyfpIx1QKQGc=";
};
2021-01-17 03:51:22 +00:00
nativeBuildInputs = [ pkg-config autoreconfHook ]
2022-12-05 01:42:22 +00:00
++ lib.concatMap(f: flavorInfo.${f}.nativeBuildInputs or []) enabledFlavors;
2022-11-14 11:53:16 +00:00
buildInputs = [ libgpg-error libassuan ]
++ lib.optional withLibsecret libsecret
2022-12-05 01:42:22 +00:00
++ lib.concatMap(f: flavorInfo.${f}.buildInputs or []) enabledFlavors;
dontWrapGApps = true;
dontWrapQtApps = true;
2015-06-25 00:13:40 +00:00
2019-09-14 11:46:39 +00:00
patches = [
./autoconf-ar.patch
2022-12-05 01:42:22 +00:00
] ++ lib.optionals (lib.elem "gtk2" enabledFlavors) [
(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";
2018-02-25 20:21:40 +00:00
sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd";
2017-12-16 02:52:37 +00:00
})
];
2015-03-25 23:09:00 +00:00
configureFlags = [
2022-11-14 11:53:16 +00:00
(lib.enableFeature withLibsecret "libsecret")
2022-12-05 01:42:22 +00:00
] ++ (map enableFeaturePinentry (lib.attrNames flavorInfo));
postInstall =
2022-12-05 01:42:22 +00:00
lib.concatStrings (lib.flip map enabledFlavors (f:
let
binary = "pinentry-" + flavorInfo.${f}.bin;
in ''
moveToOutput bin/${binary} ${placeholder f}
ln -sf ${placeholder f}/bin/${binary} ${placeholder f}/bin/pinentry
2022-12-05 01:42:22 +00:00
'' + lib.optionalString (f == "gnome3") ''
wrapGApp ${placeholder f}/bin/${binary}
2022-12-05 01:42:22 +00:00
'' + lib.optionalString (f == "qt") ''
wrapQtApp ${placeholder f}/bin/${binary}
'')) + ''
2022-12-05 01:42:22 +00:00
ln -sf ${placeholder (lib.head enabledFlavors)}/bin/pinentry-${flavorInfo.${lib.head enabledFlavors}.bin} $out/bin/pinentry
'';
outputs = [ "out" ] ++ enabledFlavors;
passthru = { flavors = enabledFlavors; };
meta = with lib; {
homepage = "http://gnupg.org/aegypten2/";
2017-12-16 02:52:37 +00:00
description = "GnuPGs interface to passphrase input";
license = licenses.gpl2Plus;
platforms = platforms.all;
longDescription = ''
Pinentry provides a console and (optional) GTK and Qt GUIs allowing users
2015-06-08 14:25:58 +00:00
to enter a passphrase when `gpg' or `gpg2' is run and needs it.
'';
maintainers = with maintainers; [ ttuegel fpletz ];
};
}