@@ -1,5 +1,5 @@
11{ stdenv, fetchurl, buildPackages, perl
2−, hostPlatform
2+, buildPlatform, hostPlatform
33, fetchpatch
44, withCryptodev ? false, cryptodevHeaders
55, enableSSL2 ? false
@@ -8,10 +8,6 @@
88with stdenv.lib;
99
1010let
11−
12− opensslCrossSystem = hostPlatform.openssl.system or
13− (throw "openssl needs its platform name cross building");
14−
1511 common = args@{ version, sha256, patches ? [] }: stdenv.mkDerivation rec {
1612 name = "openssl-${version}";
1713
@@ -24,23 +20,34 @@ let
2420 (args.patches or [])
2521 ++ [ ./nix-ssl-cert-file.patch ]
2622 ++ optional (versionOlder version "1.1.0")
27− (if stdenv.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
23+ (if hostPlatform.isDarwin then ./use-etc-ssl-certs-darwin.patch else ./use-etc-ssl-certs.patch)
2824 ++ optional (versionOlder version "1.0.2" && hostPlatform.isDarwin)
2925 ./darwin-arch.patch;
3026
3127 outputs = [ "bin" "dev" "out" "man" ];
3228 setOutputFlags = false;
33− separateDebugInfo = stdenv.isLinux;
29+ separateDebugInfo = hostPlatform.isLinux;
3430
3531 nativeBuildInputs = [ perl ];
3632 buildInputs = stdenv.lib.optional withCryptodev cryptodevHeaders;
3733
38− # On x86_64-darwin, "./config" misdetects the system as
39− # "darwin-i386-cc". So specify the system type explicitly.
40− configureScript =
41− if stdenv.system == "x86_64-darwin" then "./Configure darwin64-x86_64-cc"
42− else if stdenv.system == "x86_64-solaris" then "./Configure solaris64-x86_64-gcc"
43− else "./config";
34+ # TODO(@Ericson2314): Improve with mass rebuild
35+ configureScript = {
36+ "x86_64-darwin" = "./Configure darwin64-x86_64-cc";
37+ "x86_64-solaris" = "./Configure solaris64-x86_64-gcc";
38+ }.${hostPlatform.system} or (
39+ if hostPlatform == buildPlatform
40+ then "./config"
41+ else if hostPlatform.isMinGW
42+ then "./Configure mingw${toString hostPlatform.parsed.cpu.bits}"
43+ else if hostPlatform.isLinux
44+ then "./Configure linux-generic${toString hostPlatform.parsed.cpu.bits}"
45+ else
46+ throw "Not sure what configuration to use for ${hostPlatform.config}"
47+ );
48+
49+ # TODO(@Ericson2314): Make unconditional on mass rebuild
50+ ${if buildPlatform != hostPlatform then "configurePlatforms" else null} = [];
4451
4552 configureFlags = [
4653 "shared"
@@ -50,7 +57,7 @@ let
5057 "-DHAVE_CRYPTODEV"
5158 "-DUSE_CRYPTODEV_DIGESTS"
5259 ] ++ stdenv.lib.optional enableSSL2 "enable-ssl2"
53− ++ stdenv.lib.optional (versionAtLeast version "1.1.0" && stdenv.isAarch64) "no-afalgeng";
60+ ++ stdenv.lib.optional (versionAtLeast version "1.1.0" && hostPlatform.isAarch64) "no-afalgeng";
5461
5562 makeFlags = [ "MANDIR=$(man)/share/man" ];
5663
@@ -84,18 +91,6 @@ let
8491 fi
8592 '';
8693
87− crossAttrs = {
88− # upstream patch: https://rt.openssl.org/Ticket/Display.html?id=2558
89− postPatch = ''
90− sed -i -e 's/[$][(]CROSS_COMPILE[)]windres/$(WINDRES)/' Makefile.shared
91− '';
92− preConfigure=''
93− # It's configure does not like --build or --host
94− export configureFlags="${concatStringsSep " " (configureFlags ++ [ opensslCrossSystem ])}"
95− '';
96− configureScript = "./Configure";
97− };
98−
9994 meta = {
10095 homepage = https://www.openssl.org/;
10196 description = "A cryptographic library that implements the SSL and TLS protocols";