@@ -1,24 +1,7 @@
1−{ stdenv, fetchurl
2−, libgpgerror
1+{ lib, stdenv, fetchurl, libgpgerror, enableCapabilities ? false, libcap }:
32
4−# Optional Dependencies
5−, libcap ? null, pth ? null
6−}:
3+assert enableCapabilities -> stdenv.isLinux;
74
8−let
9− mkFlag = trueStr: falseStr: cond: name: val:
10− if cond == null then null else
11− "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
12− mkEnable = mkFlag "enable-" "disable-";
13− mkWith = mkFlag "with-" "without-";
14− mkOther = mkFlag "" "" true;
15−
16− shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
17−
18− optLibcap = shouldUsePkg libcap;
19− #optPth = shouldUsePkg pth;
20− optPth = null; # Broken as of 1.6.3
21−in
225stdenv.mkDerivation rec {
236 name = "libgcrypt-1.6.3";
247
@@ -27,29 +10,26 @@ stdenv.mkDerivation rec {
2710 sha256 = "0pq2nwfqgggrsh8rk84659d80vfnlkbphwqjwahccd5fjdxr3d21";
2811 };
2912
30− buildInputs = [ libgpgerror optLibcap optPth ];
31−
32− configureFlags = [
33− (mkWith (optLibcap != null) "capabilities" null)
34− (mkEnable (optPth != null) "random-daemon" null)
35− ];
13+ buildInputs =
14+ [ libgpgerror ]
15+ ++ lib.optional enableCapabilities libcap;
3616
3717 # Make sure libraries are correct for .pc and .la files
3818 # Also make sure includes are fixed for callers who don't use libgpgcrypt-config
3919 postInstall = ''
4020 sed -i 's,#include <gpg-error.h>,#include "${libgpgerror}/include/gpg-error.h",g' $out/include/gcrypt.h
41− '' + stdenv.lib.optionalString (!stdenv.isDarwin && optLibcap != null) ''
42− sed -i 's,\(-lcap\),-L${optLibcap}/lib \1,' $out/lib/libgcrypt.la
21+ '' + stdenv.lib.optionalString enableCapabilities ''
22+ sed -i 's,\(-lcap\),-L${libcap}/lib \1,' $out/lib/libgcrypt.la
4323 '';
4424
4525 doCheck = true;
4626
47− meta = with stdenv.lib; {
27+ meta = {
4828 homepage = https://www.gnu.org/software/libgcrypt/;
4929 description = "General-pupose cryptographic library";
50− license = licenses.lgpl2Plus;
51− platforms = platforms.all;
52− maintainers = with maintainers; [ wkennington ];
30+ license = lib.licenses.lgpl2Plus;
31+ platforms = lib.platforms.all;
32+ maintainers = [ lib.maintainers.wkennington ];
5333 repositories.git = git://git.gnupg.org/libgcrypt.git;
5434 };
5535}