1 { nixpkgsPath, revision, libsetsJSON }:
3 lib = import (nixpkgsPath + "/lib");
4 libsets = builtins.fromJSON libsetsJSON;
6 libDefPos = prefix: set:
9 name = builtins.concatStringsSep "." (prefix ++ [name]);
10 location = builtins.unsafeGetAttrPos name set;
12 (builtins.length prefix == 0 && builtins.isAttrs set.${name})
13 (libDefPos (prefix ++ [name]) set.${name})
14 ) (builtins.attrNames set);
19 subsetname = subsetname;
20 functions = libDefPos [] toplib.${subsetname};
22 (builtins.map (x: x.name) libsets);
24 flattenedLibSubset = { subsetname, functions }:
27 name = "lib.${subsetname}.${fn.name}";
32 locatedlibsets = libs: builtins.map flattenedLibSubset (libset libs);
33 removeFilenamePrefix = prefix: filename:
35 prefixLen = (builtins.stringLength prefix) + 1; # +1 to remove the leading /
36 filenameLen = builtins.stringLength filename;
37 substr = builtins.substring prefixLen filenameLen filename;
40 removeNixpkgs = removeFilenamePrefix (builtins.toString nixpkgsPath);
44 (elem: elem.value != null)
46 (locatedlibsets lib));
48 fnLocationRelative = { name, value }:
51 value = value // { file = removeNixpkgs value.file; };
54 relativeLocs = (builtins.map fnLocationRelative liblocations);
55 sanitizeId = builtins.replaceStrings
59 urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}";
60 jsonLocs = builtins.listToAttrs
63 name = sanitizeId name;
66 text = "${value.file}:${builtins.toString value.line}";
67 target = "${urlPrefix}/${value.file}#L${builtins.toString value.line}";
69 "[${text}](${target}) in `<nixpkgs>`";