2021-03-19 17:17:44 +00:00
{ lib , stdenv , fetchurl , gettext , libgpgerror , enableCapabilities ? false , libcap , buildPackages }:
2020-04-24 23:36:52 +00:00
assert enableCapabilities -> stdenv . isLinux ;
stdenv . mkDerivation rec {
pname = " l i b g c r y p t " ;
2021-03-19 17:17:44 +00:00
version = " 1 . 9 . 2 " ;
2020-04-24 23:36:52 +00:00
src = fetchurl {
url = " m i r r o r : / / g n u p g / l i b g c r y p t / ${ pname } - ${ version } . t a r . b z 2 " ;
2021-03-19 17:17:44 +00:00
sha256 = " s h a 2 5 6 - s s E N C R U T s n H k c X c n R g e x / 7 o 9 l b G I u / q H l / l I r s k F P F o = " ;
2020-04-24 23:36:52 +00:00
} ;
outputs = [ " o u t " " d e v " " i n f o " ] ;
outputBin = " d e v " ;
# The CPU Jitter random number generator must not be compiled with
# optimizations and the optimize -O0 pragma only works for gcc.
# The build enables -O2 by default for everything else.
2021-02-05 17:12:51 +00:00
hardeningDisable = lib . optional stdenv . cc . isClang " f o r t i f y " ;
2020-04-24 23:36:52 +00:00
depsBuildBuild = [ buildPackages . stdenv . cc ] ;
buildInputs = [ libgpgerror ]
2021-02-05 17:12:51 +00:00
++ lib . optional stdenv . isDarwin gettext
++ lib . optional enableCapabilities libcap ;
2020-04-24 23:36:52 +00:00
2021-03-09 03:18:52 +00:00
strictDeps = true ;
2020-04-24 23:36:52 +00:00
configureFlags = [ " - - w i t h - l i b g p g - e r r o r - p r e f i x = ${ libgpgerror . dev } " ]
2021-02-22 21:28:39 +00:00
++ lib . optional ( stdenv . hostPlatform . isMusl || ( stdenv . hostPlatform . isDarwin && stdenv . hostPlatform . isAarch64 ) ) " - - d i s a b l e - a s m " ; # for darwin see https://dev.gnupg.org/T5157
2020-04-24 23:36:52 +00:00
2020-07-18 16:06:22 +00:00
# Necessary to generate correct assembly when compiling for aarch32 on
# aarch64
configurePlatforms = [ " h o s t " " b u i l d " ] ;
2021-01-05 17:05:55 +00:00
postConfigure = ''
sed - i configure \
- e ' s/NOEXECSTACK_FLAGS = $ /NOEXECSTACK_FLAGS = " - W a , - - n o e x e c s t a c k " / '
'' ;
2020-04-24 23:36:52 +00:00
# Make sure libraries are correct for .pc and .la files
# Also make sure includes are fixed for callers who don't use libgpgcrypt-config
postFixup = ''
sed - i ' s , #include <gpg-error.h>,#include "${libgpgerror.dev}/include/gpg-error.h",g' "$dev/include/gcrypt.h"
2021-02-05 17:12:51 +00:00
'' + l i b . o p t i o n a l S t r i n g e n a b l e C a p a b i l i t i e s ''
2020-04-24 23:36:52 +00:00
sed - i ' s , \ ( - lcap \ ) , - L $ { libcap . lib } /lib \ 1 , ' $ out/lib/libgcrypt.la
'' ;
# TODO: figure out why this is even necessary and why the missing dylib only crashes
# random instead of every test
2021-02-05 17:12:51 +00:00
preCheck = lib . optionalString stdenv . isDarwin ''
2020-04-24 23:36:52 +00:00
mkdir - p $ out/lib
cp src/.libs/libgcrypt.20.dylib $ out/lib
'' ;
doCheck = true ;
2021-02-05 17:12:51 +00:00
meta = with lib ; {
2020-04-24 23:36:52 +00:00
homepage = " h t t p s : / / w w w . g n u . o r g / s o f t w a r e / l i b g c r y p t / " ;
description = " G e n e r a l - p u r p o s e c r y p t o g r a p h i c l i b r a r y " ;
license = licenses . lgpl2Plus ;
platforms = platforms . all ;
maintainers = with maintainers ; [ vrthra ] ;
repositories . git = " g i t : / / g i t . g n u p g . o r g / l i b g c r y p t . g i t " ;
} ;
}