about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/config/no-x-libs.nix1
-rw-r--r--pkgs/tools/security/pinentry/default.nix35
2 files changed, 18 insertions, 18 deletions
diff --git a/nixos/modules/config/no-x-libs.nix b/nixos/modules/config/no-x-libs.nix
index 18ea1f52a9766..e5699161ec4bc 100644
--- a/nixos/modules/config/no-x-libs.nix
+++ b/nixos/modules/config/no-x-libs.nix
@@ -43,6 +43,7 @@ with lib;
       networkmanager-openvpn = super.networkmanager-openvpn.override { withGnome = false; };
       networkmanager-sstp = super.networkmanager-vpnc.override { withGnome = false; };
       networkmanager-vpnc = super.networkmanager-vpnc.override { withGnome = false; };
+      pinentry = super.pinentry.override { enabledFlavors = [ "curses" "tty" "emacs" ]; withLibsecret = false; };
       qemu = super.qemu.override { gtkSupport = false; spiceSupport = false; sdlSupport = false; };
       zbar = super.zbar.override { enableVideo = false; withXorg = false; };
     }));
diff --git a/pkgs/tools/security/pinentry/default.nix b/pkgs/tools/security/pinentry/default.nix
index 68e72171eca4f..61f84e5d76e93 100644
--- a/pkgs/tools/security/pinentry/default.nix
+++ b/pkgs/tools/security/pinentry/default.nix
@@ -1,14 +1,13 @@
 { fetchurl, mkDerivation, fetchpatch, stdenv, lib, pkg-config, autoreconfHook, wrapGAppsHook
 , libgpg-error, libassuan, qtbase, wrapQtAppsHook
-, ncurses, gtk2, gcr, libcap, libsecret
+, ncurses, gtk2, gcr, libcap
+, withLibsecret ? true, libsecret
 , enabledFlavors ? [ "curses" "tty" "gtk2" "emacs" ]
   ++ lib.optionals stdenv.isLinux [ "gnome3" ]
   ++ lib.optionals (!stdenv.isDarwin) [ "qt" ]
 }:
 
-with lib;
-
-assert isList enabledFlavors && enabledFlavors != [];
+assert lib.isList enabledFlavors && enabledFlavors != [];
 
 let
   pinentryMkDerivation =
@@ -18,11 +17,10 @@ let
 
   enableFeaturePinentry = f:
     let
-      info = flavorInfo.${f};
       flag = flavorInfo.${f}.flag or null;
     in
-      optionalString (flag != null)
-        (enableFeature (elem f enabledFlavors) ("pinentry-" + flag));
+      lib.optionalString (flag != null)
+        (lib.enableFeature (lib.elem f enabledFlavors) ("pinentry-" + flag));
 
   flavorInfo = {
     curses = { bin = "curses"; flag = "curses"; buildInputs = [ ncurses ]; };
@@ -45,17 +43,18 @@ pinentryMkDerivation rec {
   };
 
   nativeBuildInputs = [ pkg-config autoreconfHook ]
-    ++ concatMap(f: flavorInfo.${f}.nativeBuildInputs or []) enabledFlavors;
-  buildInputs = [ libgpg-error libassuan libsecret ]
+    ++ lib.concatMap(f: flavorInfo.${f}.nativeBuildInputs or []) enabledFlavors;
+  buildInputs = [ libgpg-error libassuan ]
+    ++ lib.optional withLibsecret libsecret
     ++ lib.optional (!stdenv.isDarwin) libcap
-    ++ concatMap(f: flavorInfo.${f}.buildInputs or []) enabledFlavors;
+    ++ lib.concatMap(f: flavorInfo.${f}.buildInputs or []) enabledFlavors;
 
   dontWrapGApps = true;
   dontWrapQtApps = true;
 
   patches = [
     ./autoconf-ar.patch
-  ] ++ optionals (elem "gtk2" enabledFlavors) [
+  ] ++ 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";
       sha256 = "15r1axby3fdlzz9wg5zx7miv7gqx2jy4immaw4xmmw5skiifnhfd";
@@ -63,23 +62,23 @@ pinentryMkDerivation rec {
   ];
 
   configureFlags = [
-    (withFeature   (libcap != null)    "libcap")
-    (enableFeature (libsecret != null) "libsecret")
-  ] ++ (map enableFeaturePinentry (attrNames flavorInfo));
+    (lib.withFeature   (libcap != null) "libcap")
+    (lib.enableFeature withLibsecret    "libsecret")
+  ] ++ (map enableFeaturePinentry (lib.attrNames flavorInfo));
 
   postInstall =
-    concatStrings (flip map enabledFlavors (f:
+    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
-      '' + optionalString (f == "gnome3") ''
+      '' + lib.optionalString (f == "gnome3") ''
         wrapGApp ${placeholder f}/bin/${binary}
-      '' + optionalString (f == "qt") ''
+      '' + lib.optionalString (f == "qt") ''
         wrapQtApp ${placeholder f}/bin/${binary}
       '')) + ''
-      ln -sf ${placeholder (head enabledFlavors)}/bin/pinentry-${flavorInfo.${head enabledFlavors}.bin} $out/bin/pinentry
+      ln -sf ${placeholder (lib.head enabledFlavors)}/bin/pinentry-${flavorInfo.${lib.head enabledFlavors}.bin} $out/bin/pinentry
     '';
 
   outputs = [ "out" ] ++ enabledFlavors;