summary refs log tree commit diff
path: root/pkgs/development/libraries/libssh2/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/libssh2/default.nix')
-rw-r--r--pkgs/development/libraries/libssh2/default.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkgs/development/libraries/libssh2/default.nix b/pkgs/development/libraries/libssh2/default.nix
index a8e8777f06c..3434fde1a62 100644
--- a/pkgs/development/libraries/libssh2/default.nix
+++ b/pkgs/development/libraries/libssh2/default.nix
@@ -7,8 +7,16 @@
 , openssl ? null, libgcrypt ? null
 }:
 
-with stdenv;
 let
+  mkFlag = trueStr: falseStr: cond: name: val:
+    if cond == null then null else
+      "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
+  mkEnable = mkFlag "enable-" "disable-";
+  mkWith = mkFlag "with-" "without-";
+  mkOther = mkFlag "" "" true;
+
+  shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
+
   # Prefer openssl
   cryptoStr = if shouldUsePkg openssl != null then "openssl"
     else if shouldUsePkg libgcrypt != null then "libgcrypt"