2021-01-21 17:00:13 +00:00
{ lib , stdenv , fetchurl , gettext , libgpgerror , enableCapabilities ? false , libcap
2021-02-12 11:23:37 +00:00
, buildPackages , fetchpatch
2018-02-25 03:51:22 +00:00
} :
2015-05-02 00:39:02 +00:00
2015-06-04 09:14:24 +00:00
assert enableCapabilities -> stdenv . isLinux ;
2015-05-02 00:39:02 +00:00
stdenv . mkDerivation rec {
2019-08-15 12:41:18 +00:00
pname = " l i b g c r y p t " ;
2021-01-29 14:01:27 +00:00
version = " 1 . 9 . 1 " ;
2007-08-16 21:44:48 +00:00
src = fetchurl {
2019-08-15 12:41:18 +00:00
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-01-29 14:01:27 +00:00
sha256 = " 1 n b 5 0 b g z p 8 3 q 6 r 5 c z 4 v 4 0 y 1 m c b h p q w q y x l a y 8 7 x p 1 l r b k f 5 p m 9 n 5 " ;
2007-08-16 21:44:48 +00:00
} ;
2021-02-12 11:23:37 +00:00
patches = [
# fix build on 32bit musl
( fetchpatch {
name = " f i x _ b u i l d i n g _ w i t h _ d i s a b l e - a s m _ o n _ x 8 6 . p a t c h " ;
url = " h t t p s : / / g i t . g n u p g . o r g / c g i - b i n / g i t w e b . c g i ? p = l i b g c r y p t . g i t ; a = c o m m i t d i f f _ p l a i n ; h = a f 2 3 a b 5 c 5 4 8 2 d 6 2 5 f f 5 2 e 6 0 6 0 6 c f 0 4 4 e 2 b 0 1 0 6 c 8 " ;
sha256 = " 1 m 8 a p m 8 w r a 6 f k 8 9 g g h a 4 d 0 b b a 5 a b s i h m 3 8 z v b 2 k h k l q h 9 q 5 h j 9 j w " ;
} )
] ;
2016-08-29 00:30:01 +00:00
outputs = [ " o u t " " d e v " " i n f o " ] ;
2015-10-13 18:03:22 +00:00
outputBin = " d e v " ;
2017-08-05 13:20:13 +00:00
# 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-01-21 17:00:13 +00:00
hardeningDisable = lib . optional stdenv . cc . isClang " f o r t i f y " ;
2017-08-05 13:20:13 +00:00
2018-02-25 13:24:34 +00:00
depsBuildBuild = [ buildPackages . stdenv . cc ] ;
2018-02-25 03:51:22 +00:00
2017-08-05 13:20:13 +00:00
buildInputs = [ libgpgerror ]
2021-01-21 17:00:13 +00:00
++ lib . optional stdenv . isDarwin gettext
++ lib . optional enableCapabilities libcap ;
2008-09-09 08:48:46 +00:00
2021-02-12 11:23:37 +00:00
strictDeps = true ;
2019-10-31 10:27:43 +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-09 18:43:08 +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
2018-02-25 03:51:22 +00:00
2020-05-14 21:12:06 +00:00
# Necessary to generate correct assembly when compiling for aarch32 on
# aarch64
configurePlatforms = [ " h o s t " " b u i l d " ] ;
2020-12-26 10:27:37 +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 " / '
'' ;
2015-05-02 00:39:02 +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
2015-10-13 18:03:22 +00:00
postFixup = ''
sed - i ' s , #include <gpg-error.h>,#include "${libgpgerror.dev}/include/gpg-error.h",g' "$dev/include/gcrypt.h"
2021-01-21 17:00:13 +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 ''
2016-05-07 19:49:16 +00:00
sed - i ' s , \ ( - lcap \ ) , - L $ { libcap . lib } /lib \ 1 , ' $ out/lib/libgcrypt.la
2008-09-09 08:48:46 +00:00
'' ;
2015-08-25 19:08:59 +00:00
# TODO: figure out why this is even necessary and why the missing dylib only crashes
# random instead of every test
2021-01-21 17:00:13 +00:00
preCheck = lib . optionalString stdenv . isDarwin ''
2015-08-25 19:08:59 +00:00
mkdir - p $ out/lib
cp src/.libs/libgcrypt.20.dylib $ out/lib
'' ;
2018-06-18 00:16:35 +00:00
doCheck = true ;
2014-04-08 23:15:38 +00:00
2021-01-21 17:00:13 +00:00
meta = with lib ; {
2020-04-01 01:11:51 +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 / " ;
2017-09-02 13:56:11 +00:00
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 " ;
2016-06-23 07:32:25 +00:00
license = licenses . lgpl2Plus ;
platforms = platforms . all ;
2019-01-26 10:01:09 +00:00
maintainers = with maintainers ; [ vrthra ] ;
2020-04-01 01:11:51 +00:00
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 " ;
2008-09-09 08:48:46 +00:00
} ;
2015-05-02 00:39:02 +00:00
}