Skip to content

Instantly share code, notes, and snippets.

@ConnorBaker
Last active September 28, 2025 01:16
Show Gist options
  • Save ConnorBaker/b3f4ab28a84d40828f0df24f23aa7e26 to your computer and use it in GitHub Desktop.
Save ConnorBaker/b3f4ab28a84d40828f0df24f23aa7e26 to your computer and use it in GitHub Desktop.
Get information about CPU capabilities used by binaries in a closure
# Requires gnu find for -files0-from
# Requires elfx86exts
nix path-info -r $1 \
| tr '\n' '\0' \
| find -L -files0-from - -type f -exec sha256sum {} \+ \
| sed -E 's/([a-f0-9]+) (\/nix\/store\/[a-z0-9]{32}-(.+))/\3 \1 \2/' \
| sort -s -k 1 \
| xargs -n1 -d '\n' bash -c \
'
args=( $1 );
output=$(elfx86exts "${args[2]}" 2>/dev/null);
(( $? != 0 )) && exit 0;
echo "$1";
lines=( );
mapfile -t lines < <(echo "$output");
printf " %s\n" "${lines[@]}";
' {} > $1.txt
# Diff results
diffoscope default-nix.txt x86-64-v4-nix.txt --diff-mask "/nix/store/([a-z0-9]){32}" --diff-mask "[a-f0-9]{64}" --diff-mask "\.so(\.[0-9.]+)?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment