git.iko.soy/typeable/nixpkgs
on master help sign in
pinentry: build with multiple outputs in single drv

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

commita4916fdea5680452cb9fc5aac5ec350b52b3797c authorFranz Pletz <fpletz@fnordicwalking.de> dateSat 27 Oct 2018, 16:01 (8 years ago) parent334921a
3 files changed+75−62
nixos/modules/config/no-x-libs.nix−1 pkgs/tools/security/pinentry/default.nix+69−36 pkgs/top-level/all-packages.nix+6−25
nixos/modules/config/no-x-libs.nix−1
@@ -34,7 +34,6 @@ with lib;
3434 networkmanager-openvpn = super.networkmanager-openvpn.override { withGnome = false; };
3535 networkmanager-vpnc = super.networkmanager-vpnc.override { withGnome = false; };
3636 networkmanager-iodine = super.networkmanager-iodine.override { withGnome = false; };
37− pinentry = super.pinentry.override { gtk2 = null; gcr = null; qt4 = null; qt5 = null; };
3837 gobject-introspection = super.gobject-introspection.override { x11Support = false; };
3938 }));
4039 };
pkgs/tools/security/pinentry/default.nix+69−36
@@ -1,60 +1,93 @@
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" ]
66}:
77
8−assert qt5 != null -> qt4 == null;
9−assert qt4 != null -> qt5 == null;
8+with stdenv.lib;
9+
10+assert isList enabledFlavors && enabledFlavors != [];
1011
1112let
12− mkDerivation =
13− if qt5 != null
14− then qt5.mkDerivation
13+ pinentryMkDerivation =
14+ if (builtins.elem "qt" enabledFlavors)
15+ then mkDerivation
1516 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+
1640in
1741
18−mkDerivation rec {
19− name = "pinentry-1.1.0";
42+pinentryMkDerivation rec {
43+ pname = "pinentry";
44+ version = "1.1.0";
2045
2146 src = fetchurl {
22− url = "mirror://gnupg/pinentry/${name}.tar.bz2";
47+ url = "mirror://gnupg/pinentry/${pname}-${version}.tar.bz2";
2348 sha256 = "0w35ypl960pczg5kp6km3dyr000m1hf0vpwwlh72jjkjza36c1v8";
2449 };
2550
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;
3055
31− prePatch = ''
32− substituteInPlace pinentry/pinentry-curses.c --replace ncursesw ncurses
33− '';
56+ dontWrapGApps = true;
57+ dontWrapQtApps = true;
3458
3559 patches = [
3660 ./autoconf-ar.patch
37− ] ++ lib.optionals (gtk2 != null) [
61+ ] ++ optionals (elem "gtk2" enabledFlavors) [
3862 (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";
4164 sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd";
4265 })
4366 ];
4467
4568 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")
54−
55− "--with-libassuan-prefix=${libassuan.dev}"
56− "--with-libgpg-error-prefix=${libgpgerror.dev}"
57− ];
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; };
5891
5992 meta = with stdenv.lib; {
6093 homepage = http://gnupg.org/aegypten2/;
@@ -65,6 +98,6 @@ mkDerivation rec {
6598 Pinentry provides a console and (optional) GTK and Qt GUIs allowing users
6699 to enter a passphrase when `gpg' or `gpg2' is run and needs it.
67100 '';
68− maintainers = [ maintainers.ttuegel ];
101+ maintainers = with maintainers; [ ttuegel fpletz ];
69102 };
70103}
pkgs/top-level/all-packages.nix+6−25
@@ -5521,34 +5521,15 @@ in
55215521
55225522 phodav = callPackage ../tools/networking/phodav { };
55235523
5524− pinentry = callPackage ../tools/security/pinentry {
5524+ pinentry = libsForQt5.callPackage ../tools/security/pinentry {
55255525 libcap = if stdenv.isDarwin then null else libcap;
5526− gcr = null;
5527− qt4 = null;
5528− qt5 = null;
5529− };
5530−
5531− pinentry_ncurses = res.pinentry.override {
5532− gtk2 = null;
55335526 };
55345527
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);
55525533
55535534 pinentry_mac = callPackage ../tools/security/pinentry/mac.nix {
55545535 inherit (darwin.apple_sdk.frameworks) Cocoa;