@@ -1,10 +1,14 @@
1−{ fetchurl, stdenv, pkgconfig, glib
2−, useGtk ? !stdenv.isDarwin, gtk
3−, useNcurses ? true, ncurses
4−, useQt4 ? false, qt4 }:
5−
6−assert useGtk || useNcurses || useQt4;
7−
1+{ fetchurl, stdenv, pkgconfig
2+, libcap ? null, ncurses ? null, gtk ? null, qt4 ? null
3+}:
4+
5+let
6+ mkFlag = pfxTrue: pfxFalse: cond: name: "--${if cond then pfxTrue else pfxFalse}-${name}";
7+ mkEnable = mkFlag "enable" "disable";
8+ mkWith = mkFlag "with" "without";
9+ hasX = gtk != null || qt4 != null;
10+in
11+with stdenv.lib;
812stdenv.mkDerivation rec {
913 name = "pinentry-0.9.0";
1014
@@ -13,16 +17,15 @@ stdenv.mkDerivation rec {
1317 sha256 = "1awhajq21hcjgqfxg9czaxg555gij4bba6axrwg8w6lfmc3ml14h";
1418 };
1519
16− buildInputs = let opt = stdenv.lib.optional; in []
17− ++ opt useGtk glib
18− ++ opt useGtk gtk
19− ++ opt useNcurses ncurses
20− ++ opt useQt4 qt4;
20+ buildInputs = [ libcap gtk ncurses qt4 ];
2121
22− configureFlags = [ "--disable-pinentry-gtk" "--disable-pinentry-qt" ]
23− ++ (if useGtk || useQt4 then ["--with-x"] else ["--without-x"])
24− ++ (if useGtk then ["--enable-pinentry-gtk2"] else ["--disable-pinentry-gtk"])
25− ++ (if useQt4 then ["--enable-pinentry-qt4"] else ["--disable-pinentry-qt4"]);
22+ configureFlags = [
23+ (mkWith (libcap != null) "libcap")
24+ (mkEnable (ncurses != null) "pinentry-curses")
25+ (mkEnable true "pinentry-tty")
26+ (mkEnable (gtk != null) "pinentry-gtk2")
27+ (mkEnable (qt4 != null) "pinentry-qt4")
28+ ];
2629
2730 nativeBuildInputs = [ pkgconfig ];
2831