@@ -17,16 +17,32 @@ let
1717 nixpkgs.system = config.nixpkgs.system;
1818 };
1919
20− eval = evalModules {
21− modules = [ versionModule ] ++ baseModules;
22− args = (config._module.args) // { modules = [ ]; };
23− };
24−
20+ /* For the purpose of generating docs, evaluate options with each derivation
21+ in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}".
22+ It isn't perfect, but it seems to cover a vast majority of use cases.
23+ Caveat: even if the package is reached by a different means,
24+ the path above will be shown and not e.g. `${config.services.foo.package}`. */
2525 manual = import ../../../doc/manual {
2626 inherit pkgs;
2727 version = config.system.nixosVersion;
2828 revision = config.system.nixosRevision;
29− options = eval.options;
29+ options =
30+ let
31+ scrubbedEval = evalModules {
32+ modules = [ versionModule ] ++ baseModules;
33+ args = (config._module.args) // { modules = [ ]; };
34+ specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
35+ };
36+ scrubDerivations = namePrefix: pkgSet: mapAttrs
37+ (name: value:
38+ let wholeName = "${namePrefix}.${name}"; in
39+ if isAttrs value then
40+ scrubDerivations wholeName value
41+ // (optionalAttrs (isDerivation value) { outPath = "\${${wholeName}}"; })
42+ else value
43+ )
44+ pkgSet;
45+ in scrubbedEval.options;
3046 };
3147
3248 entry = "${manual.manual}/share/doc/nixos/index.html";