about summary refs log tree commit diff
path: root/tools/nixery/group-layers/popcount.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-08-12T16·47+0100
committerVincent Ambo <github@tazj.in>2019-08-13T23·02+0100
commit6035bf36eb93bc30db6ac40739913358e71d1121 (patch)
tree360e479422e04b75c2b5b920ced12886a44f7e74 /tools/nixery/group-layers/popcount.nix
parent6d718bf2713a7e2209197247976390b878f51313 (diff)
feat(popcount): Clean up popularity counting script
Adds the script used to generate the popularity information for all of
nixpkgs.

The README lists the (currently somewhat rough) usage instructions.
Diffstat (limited to 'tools/nixery/group-layers/popcount.nix')
-rw-r--r--tools/nixery/group-layers/popcount.nix51
1 files changed, 0 insertions, 51 deletions
diff --git a/tools/nixery/group-layers/popcount.nix b/tools/nixery/group-layers/popcount.nix
deleted file mode 100644
index e21d7367724b..000000000000
--- a/tools/nixery/group-layers/popcount.nix
+++ /dev/null
@@ -1,51 +0,0 @@
-{ pkgs ? import <nixpkgs> { config.allowUnfree = false; }
-, target }:
-
-let
-  inherit (pkgs) coreutils runCommand writeText;
-  inherit (builtins) replaceStrings readFile toFile fromJSON toJSON foldl' listToAttrs;
-
-  path = [ pkgs."${target}" ];
-
-  # graphJSON abuses feature in Nix that makes structured runtime
-  # closure information available to builders. This data is imported
-  # back via IFD to process it for layering data.
-  graphJSON =
-    path:
-    runCommand "build-graph" {
-      __structuredAttrs = true;
-      exportReferencesGraph.graph = path;
-      PATH = "${coreutils}/bin";
-      builder = toFile "builder" ''
-        . .attrs.sh
-        cat .attrs.json > ''${outputs[out]}
-      '';
-    } "";
-
-  buildClosures = paths: (fromJSON (readFile (graphJSON paths)));
-
-  buildGraph = paths: listToAttrs (map (c: {
-    name = c.path;
-    value = {
-    inherit (c) closureSize references;
-    };
-  }) (buildClosures paths));
-
-  # Nix does not allow attrbute set keys to refer to store paths, but
-  # we need them to for the purpose of the calculation. To work around
-  # it, the store path prefix is replaced with the string 'closure/'
-  # and later replaced again.
-  fromStorePath = replaceStrings [ "/nix/store" ] [ "closure/" ];
-  toStorePath = replaceStrings [ "closure/" ] [ "/nix/store/" ];
-
-  buildTree = paths:
-  let
-    graph = buildGraph paths;
-    top = listToAttrs (map (p: {
-      name = fromStorePath (toString p);
-      value = {};
-    }) paths);
-  in top;
-
-  outputJson = thing: writeText "the-thing.json" (builtins.toJSON thing);
-in outputJson (buildClosures path).graph