Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Last active June 11, 2016 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverca22/d9fa5f0043153ba8c1020b30f6518c9c to your computer and use it in GitHub Desktop.
Save cleverca22/d9fa5f0043153ba8c1020b30f6518c9c to your computer and use it in GitHub Desktop.
{ stdenv, runCommand }:
let
target = if stdenv.system == "armv6l-linux" then "Tag_CPU_arch: v6" else
(if stdenv.system == "armv7l-linux" then "Tag_CPU_arch: v7" else "");
in
runCommand "enforce-arch" {} ''
mkdir -p $out/nix-support
cat <<EOF > $out/nix-support/setup-hook
function enforceArch() {
for x in $out/lib/*.so; do
readelf -A $x | grep ${target}
done
}
postInstallHooks+=(enforceArch)
EOF
''
[root@nix1:~/x]# /nix/store/12rqmlsxcff4k1dhpip0k3hp4a7dc2dp-binutils-2.26/bin/readelf -A /nix/store/l6dx0mb19zab4ym1rh4cwdq55592v1qr-openssl-1.0.2h/lib/libcrypto.so.1.0.0
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
[root@router:~]# nix-store --query --deriver /nix/store/l6dx0mb19zab4ym1rh4cwdq55592v1qr-openssl-1.0.2h/
/nix/store/apd8lpq2y3p94l5m67axfr4jqzw6xai9-openssl-1.0.2h.drv
[root@router:~]# cat /nix/store/apd8lpq2y3p94l5m67axfr4jqzw6xai9-openssl-1.0.2h.drv
...."),("system","armv6l-linux")])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment