tvl-depot/tools/nixery/group-layers/popcount
Vincent Ambo 590ce994bb feat(group-layers): Add initial popcount scripts
This script generates an entry in a text file for each time a
derivation is referred to by another in nixpkgs.

For initial testing, this output can be turned into group-layers
compatible JSON with this *trivial* invocation:

cat output | awk '{ print "{\"" $2 "\":" $1 "}"}' | jq -s '. | add | with_entries(.key |= sub("/nix/store/[a-z0-9]+-";""))' > test-data.json
2019-08-14 00:02:04 +01:00

13 lines
356 B
Bash
Executable file

#!/bin/bash
set -ueo pipefail
function graphsFor() {
local pkg="${1}"
local graphs=$(nix-build --timeout 2 --argstr target "${pkg}" popcount.nix || echo -n 'empty.json')
cat $graphs | jq -r -cM '.[] | .references[]'
}
for pkg in $(cat all-top-level.json | jq -r '.[]'); do
graphsFor "${pkg}" 2>/dev/null
echo "Printed refs for ${pkg}" >&2
done