Created
May 11, 2023 20:12
-
-
Save infinisil/95c7013db62e9f23ab2bc92165a37221 to your computer and use it in GitHub Desktop.
Distribution of shards in Nixpkgs for RFC 140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
system ? builtins.currentSystem, | |
nixpkgs ? fetchTarball { | |
url = "https://github.com/NixOS/nixpkgs/tarball/6948ef4deff7a72ebe5242244bd3730e8542b925"; | |
sha256 = "1fw8vlbcxr3kw96rrjlw94zhbjs3a32dcnvav19cvniwlbhf2jsh"; | |
}, | |
}: | |
let | |
pkgs = import nixpkgs { | |
inherit system; | |
config.allowAliases = false; | |
overlays = []; | |
}; | |
inherit (pkgs) lib; | |
set = pkgs; | |
names = lib.attrNames set; | |
attributeCount = lib.length names; | |
grouped = lib.groupBy (name: | |
lib.toLower (lib.substring 0 2 name) | |
) names; | |
distribution = lib.sort (a: b: a.count < b.count) | |
(lib.mapAttrsToList (name: values: { | |
inherit name; | |
count = lib.length values; | |
}) grouped); | |
shardCount = lib.length distribution; | |
top20 = lib.drop (shardCount - 20) distribution; | |
result = | |
builtins.trace "Attribute count: ${toString attributeCount}" | |
builtins.trace "Shard count: ${toString shardCount}" | |
builtins.trace "Top 20" | |
(lib.foldl' (acc: el: | |
builtins.trace "${el.name}: ${toString el.count}" acc | |
) null top20); | |
in { | |
inherit result; | |
} |
Author
infinisil
commented
May 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment