Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{ 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
You can’t perform that action at this time.