Skip to content

Instantly share code, notes, and snippets.

@groxxda
Last active May 15, 2023 17:45
Show Gist options
  • Save groxxda/669e350b5494a94e093d0262221bf3e3 to your computer and use it in GitHub Desktop.
Save groxxda/669e350b5494a94e093d0262221bf3e3 to your computer and use it in GitHub Desktop.

find fetchgits

nix-instantiate --eval --strict --json ./find-fetchgits.nix --show-trace > res-find-fetchgits.json

run the prefetch-git commands

(jq -c '.[]' res-find-fetchgits.json | while read i ; do echo $i | jq '.attrPath' ; $(echo $i | jq -r '.cmd') 2>> prefetch-debug.log | tee -a prefetch.log | jq .sha256; done) | tee prefetch-short.log

identify broken srcs

grep -Pzo '\n"[^"]*src"\n(?=[^\n]+src")' prefetch-short.log

remove broken srcs

cp prefetch-short.log prefetch-short-nobroken.log
for i in $(grep -Pzo '"[^"]*src"\n(?=[^\n]+src")' prefetch-short.log) ; do sed -i "/$i/d" prefetch-short-nobroken.log ; done

build a json

(echo '{' ; sed '/"$/{N;s/^//;s/\n/: /;s/$/,/}' prefetch-short-nobroken.log ; echo '"":""}') >> prefetch-short-nobroken.json

XXX d'oh, manually remove ,\n"":"" at end of prefetch-short-nobroken.json

combine the new and old hashes into a single json

(echo '{'; (jq '.|keys[]' prefetch-short-nobroken.json | while read i ; do echo "$i: {" ; echo '"oldHash":'; jq '.[] | select(.attrPath == '$i') | .oldHash' res-find-fetchgits.json ; echo ',"newHash":'; jq '.'$i prefetch-short-nobroken.json ; echo '},'; done) ; echo '"":""}')  | jq . >> hashcomp.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment