doc: Prevent evaluation warnings

Problem: `nix-build doc` gives a bunch of warnings because it inspects
`lib` to figure out where all the symbols are.

Solution: Move the step of figuring out where the symbols are to
a Nix evaluation inside a derivation instead.
This commit is contained in:
Silvan Mosberger 2024-07-18 23:33:29 +02:00
parent a0812b380b
commit f01573b6ee
2 changed files with 23 additions and 17 deletions

View file

@ -1,13 +1,14 @@
{ pkgs, nixpkgs ? { }, libsets }:
{ nixpkgsPath, revision, libsetsJSON }:
let
revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.rev or "master");
lib = import (nixpkgsPath + "/lib");
libsets = builtins.fromJSON libsetsJSON;
libDefPos = prefix: set:
builtins.concatMap
(name: [{
name = builtins.concatStringsSep "." (prefix ++ [name]);
location = builtins.unsafeGetAttrPos name set;
}] ++ nixpkgsLib.optionals
}] ++ lib.optionals
(builtins.length prefix == 0 && builtins.isAttrs set.${name})
(libDefPos (prefix ++ [name]) set.${name})
) (builtins.attrNames set);
@ -20,8 +21,6 @@ let
})
(builtins.map (x: x.name) libsets);
nixpkgsLib = pkgs.lib;
flattenedLibSubset = { subsetname, functions }:
builtins.map
(fn: {
@ -38,13 +37,13 @@ let
substr = builtins.substring prefixLen filenameLen filename;
in substr;
removeNixpkgs = removeFilenamePrefix (builtins.toString pkgs.path);
removeNixpkgs = removeFilenamePrefix (builtins.toString nixpkgsPath);
liblocations =
builtins.filter
(elem: elem.value != null)
(nixpkgsLib.lists.flatten
(locatedlibsets nixpkgsLib));
(lib.lists.flatten
(locatedlibsets lib));
fnLocationRelative = { name, value }:
{
@ -72,4 +71,4 @@ let
relativeLocs);
in
pkgs.writeText "locations.json" (builtins.toJSON jsonLocs)
jsonLocs