<commit_before>{ pkgs, stdenv, nodejs, fetchurl, neededNatives }:

let
  inherit (self) buildNodePackage patchLatest;

  importGeneratedPackages = generated: nativeDeps: self: builtins.listToAttrs (pkgs.lib.fold (pkg: pairs:
    (pkgs.lib.optional pkg.topLevel { name = pkg.baseName; value = builtins.getAttr pkg.fullName self; }) ++ [
      {
        name = pkg.fullName;
        value = buildNodePackage rec {
          name = "${pkg.baseName}-${pkg.version}";
          src = (if pkg.patchLatest then patchLatest else fetchurl) {
            url = "http://registry.npmjs.org/${pkg.baseName}/-/${name}.tgz";
            sha256 = pkg.hash;
          };
          deps = map (dep: builtins.getAttr "${dep.name}-${dep.range}" self) pkg.dependencies;
          buildInputs = if builtins.hasAttr name nativeDeps then builtins.getAttr name nativeDeps else [];
        };
      }
    ] ++ pairs
  ) [] generated);

  self = {
    inherit importGeneratedPackages;

    nativeDeps = {
      "node-expat-*" = [ pkgs.expat ];
      "rbytes-0.0.2" = [ pkgs.openssl ];
    };

    buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
      inherit stdenv nodejs neededNatives;
      inherit (pkgs) runCommand;
    };

    patchLatest = srcAttrs:
      let src = fetchurl srcAttrs; in pkgs.runCommand src.name {} ''
        mkdir unpack<commit_msg>node-packages.nix: Move non top-level attrs to a sub-attr `full'<commit_after>{ pkgs, stdenv, nodejs, fetchurl, neededNatives }:

let
  inherit (self) buildNodePackage patchLatest;

  importGeneratedPackages = generated: nativeDeps: self:
    let
      all = pkgs.lib.fold (pkg: { top-level, full }: {
        top-level = top-level ++ pkgs.lib.optional pkg.topLevel {
          name = pkg.baseName;
          value = builtins.getAttr pkg.fullName self.full;
        };
        full = [ {
          name = pkg.fullName;
          value = buildNodePackage rec {
            name = "${pkg.baseName}-${pkg.version}";
            src = (if pkg.patchLatest then patchLatest else fetchurl) {
              url = "http://registry.npmjs.org/${pkg.baseName}/-/${name}.tgz";
              sha256 = pkg.hash;
            };
            deps = map (dep: builtins.getAttr "${dep.name}-${dep.range}" self.full) pkg.dependencies;
            buildInputs = if builtins.hasAttr name nativeDeps then builtins.getAttr name nativeDeps else [];
          };
        } ] ++ full;
      } ) { top-level = []; full = []; } generated;
    in builtins.listToAttrs all.top-level // { full = builtins.listToAttrs all.full; };

  self = {
    inherit importGeneratedPackages;

    nativeDeps = {
      "node-expat-*" = [ pkgs.expat ];
      "rbytes-0.0.2" = [ pkgs.openssl ];
    };

    buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
      inherit stdenv nodejs neededNatives;
      inherit (pkgs) runCommand;
    };

    patchLatest = srcAttrs:
      let src = fetchurl srcAttrs; in pkgs.runCommand src.name {} ''
        mkdir unpack
{'fraction_non_alphanumeric': 0.1328437917222964, 'fraction_numerical': 0.004005340453938585, 'mean_word_length': 2.3826185101580135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7464947', 'n_tokens_mistral': 989, 'n_tokens_neox': 934, 'n_words': 206}