cleverca22
8/22/2016 - 5:38 AM

enforce-arch.nix

diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index 8c0ad10..2ba92f9 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -1,5 +1,5 @@
 { stdenv, fetchurl, perl
-, withCryptodev ? false, cryptodevHeaders }:
+, withCryptodev ? false, cryptodevHeaders, enforceArch }:
 
 with stdenv.lib;
 
@@ -26,7 +26,7 @@ let
   outputs = [ "dev" "out" "man" "bin" ];
   setOutputFlags = false;
 
-    nativeBuildInputs = [ perl ];
+    nativeBuildInputs = [ perl enforceArch ];
     buildInputs = stdenv.lib.optional withCryptodev cryptodevHeaders;
 
     # On x86_64-darwin, "./config" misdetects the system as
function enforceArch() {
  echo checking target arches
  for x in $out/lib/*.so; do
    echo checking $x
    readelf -A $x | grep "@target@"
  done
}
postInstallHooks+=(enforceArch)
{ stdenv, makeSetupHook }:

let
  target = if builtins.trace "system is ${stdenv.system}" stdenv.system == "armv6l-linux" then "Tag_CPU_arch: v6" else
    (if stdenv.system == "armv7l-linux" then "Tag_CPU_arch: v7" else "NOP");
in
if target == "NOP" then
    makeSetupHook {} ./nop.sh
else
    makeSetupHook { substitutions = { inherit target; NIX_DEBUG="1"; }; } ./enforce-arch.sh