diff --git a/nixos/modules/misc/documentation.nix b/nixos/modules/misc/documentation.nix index b7746ddc2115..361815b48d52 100644 --- a/nixos/modules/misc/documentation.nix +++ b/nixos/modules/misc/documentation.nix @@ -67,11 +67,19 @@ let (t == "directory" -> baseNameOf n != "tests") && (t == "file" -> hasSuffix ".nix" n) ); + # When working directly from a checkout, + # produce separate, smaller store paths + # When already in the store, + # avoid copying; reuse the whole nixpkgs sources + pull = dir: + if isStorePath pkgs.path + then "${pkgs.path}/${dir}" + else filter "${toString pkgs.path}/${dir}"; in pkgs.runCommand "lazy-options.json" { - libPath = filter "${toString pkgs.path}/lib"; - pkgsLibPath = filter "${toString pkgs.path}/pkgs/pkgs-lib"; - nixosPath = filter "${toString pkgs.path}/nixos"; + libPath = pull "lib"; + pkgsLibPath = pull "pkgs/pkgs-lib"; + nixosPath = pull "nixos"; modules = map (p: ''"${removePrefix "${modulesPath}/" (toString p)}"'') docModules.lazy; } '' export NIX_STORE_DIR=$TMPDIR/store