2017-01-14 11:54:53 -08:00
|
|
|
|
{ stdenv, fetchurl, buildPackages, perl
|
2018-01-26 17:40:05 -08:00
|
|
|
|
, buildPlatform, hostPlatform
|
2016-10-12 05:36:00 -07:00
|
|
|
|
, withCryptodev ? false, cryptodevHeaders
|
2017-06-28 08:57:01 -07:00
|
|
|
|
, enableSSL2 ? false
|
2018-07-20 19:41:01 -07:00
|
|
|
|
, static ? false
|
2017-06-28 08:57:01 -07:00
|
|
|
|
}:
|
2008-04-23 00:34:20 -07:00
|
|
|
|
|
2015-06-20 14:26:47 -07:00
|
|
|
|
with stdenv.lib;
|
2016-02-03 04:54:22 -08:00
|
|
|
|
|
2010-03-05 15:22:36 -08:00
|
|
|
|
let
|
2017-03-04 12:40:50 -08:00
|
|
|
|
common = args@{ version, sha256, patches ? [] }: stdenv.mkDerivation rec {
|
2016-02-03 04:54:22 -08:00
|
|
|
|
name = "openssl-${version}";
|
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2018-06-28 11:43:35 -07:00
|
|
|
|
url = "https://www.openssl.org/source/${name}.tar.gz";
|
2016-02-03 04:54:22 -08:00
|
|
|
|
inherit sha256;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
patches =
|
2016-08-27 19:53:13 -07:00
|
|
|
|
(args.patches or [])
|
2017-03-20 06:11:20 -07:00
|
|
|
|
++ [ ./nix-ssl-cert-file.patch ]
|
2017-03-22 04:09:09 -07:00
|
|
|
|
++ optional (versionOlder version "1.1.0")
|
2018-01-26 17:40:05 -08:00
|
|
|
|
(if hostPlatform.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
|
2017-06-28 08:57:01 -07:00
|
|
|
|
++ optional (versionOlder version "1.0.2" && hostPlatform.isDarwin)
|
2016-02-24 05:01:20 -08:00
|
|
|
|
./darwin-arch.patch;
|
2010-07-18 14:54:14 -07:00
|
|
|
|
|
2018-02-11 14:57:48 -08:00
|
|
|
|
postPatch = if (versionAtLeast version "1.1.0" && stdenv.hostPlatform.isMusl) then ''
|
2017-08-13 13:32:50 -07:00
|
|
|
|
substituteInPlace crypto/async/arch/async_posix.h \
|
|
|
|
|
--replace '!defined(__ANDROID__) && !defined(__OpenBSD__)' \
|
|
|
|
|
'!defined(__ANDROID__) && !defined(__OpenBSD__) && 0'
|
|
|
|
|
'' else null;
|
|
|
|
|
|
2017-01-27 12:28:42 -08:00
|
|
|
|
outputs = [ "bin" "dev" "out" "man" ];
|
|
|
|
|
setOutputFlags = false;
|
2018-01-26 17:40:05 -08:00
|
|
|
|
separateDebugInfo = hostPlatform.isLinux;
|
2013-06-11 05:28:49 -07:00
|
|
|
|
|
2016-02-03 04:54:22 -08:00
|
|
|
|
nativeBuildInputs = [ perl ];
|
|
|
|
|
buildInputs = stdenv.lib.optional withCryptodev cryptodevHeaders;
|
|
|
|
|
|
2018-01-26 17:40:05 -08:00
|
|
|
|
# TODO(@Ericson2314): Improve with mass rebuild
|
|
|
|
|
configureScript = {
|
|
|
|
|
"x86_64-darwin" = "./Configure darwin64-x86_64-cc";
|
|
|
|
|
"x86_64-solaris" = "./Configure solaris64-x86_64-gcc";
|
|
|
|
|
}.${hostPlatform.system} or (
|
|
|
|
|
if hostPlatform == buildPlatform
|
|
|
|
|
then "./config"
|
|
|
|
|
else if hostPlatform.isMinGW
|
2018-07-20 18:49:53 -07:00
|
|
|
|
then "./Configure mingw${optionalString
|
|
|
|
|
(hostPlatform.parsed.cpu.bits != 32)
|
|
|
|
|
(toString hostPlatform.parsed.cpu.bits)}"
|
2018-01-26 17:40:05 -08:00
|
|
|
|
else if hostPlatform.isLinux
|
|
|
|
|
then "./Configure linux-generic${toString hostPlatform.parsed.cpu.bits}"
|
2018-04-30 22:13:44 -07:00
|
|
|
|
else if hostPlatform.isiOS
|
|
|
|
|
then "./Configure ios${toString hostPlatform.parsed.cpu.bits}-cross"
|
2018-01-26 17:40:05 -08:00
|
|
|
|
else
|
|
|
|
|
throw "Not sure what configuration to use for ${hostPlatform.config}"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
# TODO(@Ericson2314): Make unconditional on mass rebuild
|
|
|
|
|
${if buildPlatform != hostPlatform then "configurePlatforms" else null} = [];
|
2016-02-03 04:54:22 -08:00
|
|
|
|
|
2018-01-13 10:51:32 -08:00
|
|
|
|
preConfigure = ''
|
|
|
|
|
patchShebangs Configure
|
|
|
|
|
'';
|
|
|
|
|
|
2016-02-03 04:54:22 -08:00
|
|
|
|
configureFlags = [
|
2018-07-20 19:41:01 -07:00
|
|
|
|
"shared" # "shared" builds both shared and static libraries
|
2016-02-03 04:54:22 -08:00
|
|
|
|
"--libdir=lib"
|
|
|
|
|
"--openssldir=etc/ssl"
|
|
|
|
|
] ++ stdenv.lib.optionals withCryptodev [
|
|
|
|
|
"-DHAVE_CRYPTODEV"
|
|
|
|
|
"-DUSE_CRYPTODEV_DIGESTS"
|
2017-08-06 05:54:48 -07:00
|
|
|
|
] ++ stdenv.lib.optional enableSSL2 "enable-ssl2"
|
2018-01-26 17:40:05 -08:00
|
|
|
|
++ stdenv.lib.optional (versionAtLeast version "1.1.0" && hostPlatform.isAarch64) "no-afalgeng";
|
2008-10-09 07:29:06 -07:00
|
|
|
|
|
2017-01-27 12:28:42 -08:00
|
|
|
|
makeFlags = [ "MANDIR=$(man)/share/man" ];
|
2011-11-04 11:48:25 -07:00
|
|
|
|
|
2018-04-20 05:55:01 -07:00
|
|
|
|
enableParallelBuilding = true;
|
2012-11-23 08:24:35 -08:00
|
|
|
|
|
2018-07-20 19:41:01 -07:00
|
|
|
|
postInstall =
|
|
|
|
|
stdenv.lib.optionalString (!static) ''
|
2016-02-03 04:54:22 -08:00
|
|
|
|
# If we're building dynamic libraries, then don't install static
|
|
|
|
|
# libraries.
|
|
|
|
|
if [ -n "$(echo $out/lib/*.so $out/lib/*.dylib $out/lib/*.dll)" ]; then
|
|
|
|
|
rm "$out/lib/"*.a
|
|
|
|
|
fi
|
2012-08-24 20:42:33 -07:00
|
|
|
|
|
2018-07-20 19:41:01 -07:00
|
|
|
|
'' +
|
|
|
|
|
''
|
2016-04-16 09:26:31 -07:00
|
|
|
|
mkdir -p $bin
|
|
|
|
|
mv $out/bin $bin/
|
2012-08-24 20:42:33 -07:00
|
|
|
|
|
2016-04-16 09:26:31 -07:00
|
|
|
|
mkdir $dev
|
|
|
|
|
mv $out/include $dev/
|
2011-02-09 07:27:34 -08:00
|
|
|
|
|
2016-02-03 04:54:22 -08:00
|
|
|
|
# remove dependency on Perl at runtime
|
2016-04-16 09:26:31 -07:00
|
|
|
|
rm -r $out/etc/ssl/misc
|
2012-01-06 13:31:29 -08:00
|
|
|
|
|
2016-02-03 04:54:22 -08:00
|
|
|
|
rmdir $out/etc/ssl/{certs,private}
|
2015-10-30 07:38:07 -07:00
|
|
|
|
'';
|
2016-02-03 04:54:22 -08:00
|
|
|
|
|
|
|
|
|
postFixup = ''
|
2016-04-16 09:26:31 -07:00
|
|
|
|
# Check to make sure the main output doesn't depend on perl
|
2017-01-14 11:54:53 -08:00
|
|
|
|
if grep -r '${buildPackages.perl}' $out; then
|
2016-02-03 04:54:22 -08:00
|
|
|
|
echo "Found an erroneous dependency on perl ^^^" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2010-03-05 15:22:36 -08:00
|
|
|
|
'';
|
2016-02-03 04:54:22 -08:00
|
|
|
|
|
|
|
|
|
meta = {
|
2017-08-17 14:56:35 -07:00
|
|
|
|
homepage = https://www.openssl.org/;
|
2016-02-03 04:54:22 -08:00
|
|
|
|
description = "A cryptographic library that implements the SSL and TLS protocols";
|
|
|
|
|
platforms = stdenv.lib.platforms.all;
|
2016-05-16 13:30:20 -07:00
|
|
|
|
maintainers = [ stdenv.lib.maintainers.peti ];
|
2016-02-03 04:54:22 -08:00
|
|
|
|
priority = 10; # resolves collision with ‘man-pages’
|
|
|
|
|
};
|
2010-03-05 15:22:36 -08:00
|
|
|
|
};
|
|
|
|
|
|
2016-02-03 04:54:22 -08:00
|
|
|
|
in {
|
|
|
|
|
|
2016-03-01 06:25:53 -08:00
|
|
|
|
openssl_1_0_2 = common {
|
2018-03-27 10:36:12 -07:00
|
|
|
|
version = "1.0.2o";
|
|
|
|
|
sha256 = "0kcy13l701054nhpbd901mz32v1kn4g311z0nifd83xs2jbmqgzc";
|
2016-03-01 06:25:53 -08:00
|
|
|
|
};
|
2016-02-03 04:54:22 -08:00
|
|
|
|
|
2016-08-26 00:38:19 -07:00
|
|
|
|
openssl_1_1_0 = common {
|
2018-03-27 10:40:12 -07:00
|
|
|
|
version = "1.1.0h";
|
|
|
|
|
sha256 = "05x509lccqjscgyi935z809pwfm708islypwhmjnb6cyvrn64daq";
|
2018-08-06 13:29:38 -07:00
|
|
|
|
patches = [
|
|
|
|
|
./revert-relaxed-quoting.patch
|
|
|
|
|
];
|
2016-08-26 00:38:19 -07:00
|
|
|
|
};
|
|
|
|
|
|
2010-07-18 14:54:14 -07:00
|
|
|
|
}
|