3e5279aeff
Change-Id: I3798e1c23d6b0580b99b14bb4aae1c7cfc81fb6e Reviewed-on: https://cl.tvl.fyi/c/depot/+/9366 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> |
||
---|---|---|
.. | ||
default.nix | ||
popcount.go | ||
README.md |
popcount
This script is used to count the popularity for each package in nixpkgs
, by
determining how many other packages depend on it.
It skips over all packages that fail to build, are not cached or are unfree - but these omissions do not meaningfully affect the statistics.
It currently does not evaluate nested attribute sets (such as
haskellPackages
).
Usage
-
Generate a list of all top-level attributes in
nixpkgs
:nix eval '(with builtins; toJSON (attrNames (import <nixpkgs> {})))' | jq -r | jq > all-top-level.json
-
Run
./popcount > all-runtime-deps.txt
-
Collect and count the results with the following magic incantation:
cat all-runtime-deps.txt \ | sed -r 's|/nix/store/[a-z0-9]+-||g' \ | sort \ | uniq -c \ | sort -n -r \ | awk '{ print "{\"" $2 "\":" $1 "}"}' \ | jq -c -s '. | add | with_entries(select(.value > 1))' \ > your-output-file
In essence, this will trim Nix's store paths and hashes from the output, count the occurrences of each package and return the output as JSON. All packages that have no references other than themselves are removed from the output.