Merge pull request #156992 from hercules-ci/revert-153594-doc-optimization

Revert 153594 doc optimization

authored by Robert Hensing and committed by GitHub d0947df0 8328d4a5

+6 -94
+1 -5
flake.nix
··· 48 48 system.nixos.versionSuffix = 49 49 ".${final.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}"; 50 50 system.nixos.revision = final.mkIf (self ? rev) self.rev; 51 - 52 - # NOTE: This assumes that `nixpkgs.config` is _not_ used when 53 - # nixpkgs.pkgs is set OR _module.args.pkgs is set. 54 - nixpkgs.config.path = self.outPath; 55 51 } 56 52 ]; 57 53 }); ··· 66 62 }).nixos.manual.x86_64-linux; 67 63 }; 68 64 69 - legacyPackages = forAllSystems (system: import ./. { inherit system; config.path = self.outPath; }); 65 + legacyPackages = forAllSystems (system: import ./. { inherit system; }); 70 66 71 67 nixosModules = { 72 68 notDetected = import ./nixos/modules/installer/scan/not-detected.nix;
+4 -72
nixos/modules/misc/documentation.nix
··· 61 61 in scrubbedEval.options; 62 62 baseOptionsJSON = 63 63 let 64 - filterIntoStore = 64 + filter = 65 65 builtins.filterSource 66 66 (n: t: 67 67 (t == "directory" -> baseNameOf n != "tests") 68 68 && (t == "file" -> hasSuffix ".nix" n) 69 69 ); 70 - 71 - # Figure out if Nix runs in pure evaluation mode. May return true in 72 - # impure mode, but this is highly unlikely. 73 - # We need to know because of https://github.com/NixOS/nix/issues/1888 74 - # and https://github.com/NixOS/nix/issues/5868 75 - isPureEval = builtins.getEnv "PATH" == "" && builtins.getEnv "_" == ""; 76 - 77 - # Return a nixpkgs subpath with minimal copying. 78 - # 79 - # The sources for the base options json derivation can come in one of 80 - # two forms: 81 - # - single source: a store path with all of nixpkgs, postfix with 82 - # subpaths to access various directories. This has the benefit of 83 - # not creating copies of these subtrees in the Nix store, but 84 - # can cause unnecessary rebuilds if you update the Nixpkgs `pkgs` 85 - # tree often. 86 - # - split sources: multiple store paths with subdirectories of 87 - # nixpkgs that exclude the bulk of the pkgs directory. 88 - # This requires more copying and hashing during evaluation but 89 - # requires fewer files to be copied. This method produces fewer 90 - # unnecessary rebuilds of the base options json. 91 - # 92 - # Flake 93 - # 94 - # Flakes always put a copy of the full nixpkgs sources in the store, 95 - # so we can use the "single source" method. This method is ideal 96 - # for using nixpkgs as a dependency, as the base options json will be 97 - # substitutable from cache.nixos.org. 98 - # 99 - # This requires that the `self.outPath` is wired into `pkgs` correctly, 100 - # which is done for you if `pkgs` comes from the `lib.nixosSystem` or 101 - # `legacyPackages` flake attributes. 102 - # 103 - # Other Nixpkgs invocation 104 - # 105 - # If you do not use the known-correct flake attributes, but rather 106 - # invoke Nixpkgs yourself, set `config.path` to the correct path value, 107 - # e.g. `import nixpkgs { config.path = nixpkgs; }`. 108 - # 109 - # Choosing between single or split source paths 110 - # 111 - # We make assumptions based on the type and contents of `pkgs.path`. 112 - # By passing a different `config.path` to Nixpkgs, you can influence 113 - # how your documentation cache is evaluated and rebuilt. 114 - # 115 - # Single source 116 - # - If pkgs.path is a string containing a store path, the code has no 117 - # choice but to create this store path, if it hasn't already been. 118 - # We assume that the "single source" method is most efficient. 119 - # - If pkgs.path is a path value containing that is a store path, 120 - # we try to convert it to a string with context without copying. 121 - # This occurs for example when nixpkgs was fetched and using its 122 - # default `config.path`, which is `./.`. 123 - # Nix currently does not allow this conversion when evaluating in 124 - # pure mode. If the conversion is not possible, we use the 125 - # "split source" method. 126 - # 127 - # Split source 128 - # - If pkgs.path is a path value that is not a store path, we assume 129 - # that it's unlikely for all of nixpkgs to end up in the store for 130 - # other reasons and try to keep both the copying and rebuilds low. 131 - pull = 132 - if builtins.typeOf pkgs.path == "string" && isStorePath pkgs.path then 133 - dir: "${pkgs.path}/${dir}" 134 - else if !isPureEval && isStorePath pkgs.path then 135 - dir: "${builtins.storePath pkgs.path}/${dir}" 136 - else 137 - dir: filterIntoStore "${toString pkgs.path}/${dir}"; 138 70 in 139 71 pkgs.runCommand "lazy-options.json" { 140 - libPath = pull "lib"; 141 - pkgsLibPath = pull "pkgs/pkgs-lib"; 142 - nixosPath = pull "nixos"; 72 + libPath = filter "${toString pkgs.path}/lib"; 73 + pkgsLibPath = filter "${toString pkgs.path}/pkgs/pkgs-lib"; 74 + nixosPath = filter "${toString pkgs.path}/nixos"; 143 75 modules = map (p: ''"${removePrefix "${modulesPath}/" (toString p)}"'') docModules.lazy; 144 76 } '' 145 77 export NIX_STORE_DIR=$TMPDIR/store
-2
nixos/modules/misc/nixpkgs.nix
··· 59 59 inherit (cfg) config overlays localSystem crossSystem; 60 60 }; 61 61 62 - # NOTE: flake.nix assumes that nixpkgs.config is only used with ../../.. 63 - # as nixpkgs.config.path should be equivalent to ../../.. 64 62 finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs; 65 63 66 64 in
+1 -1
pkgs/top-level/all-packages.nix
··· 67 67 clangStdenvNoLibs = mkStdenvNoLibs clangStdenv; 68 68 69 69 # For convenience, allow callers to get the path to Nixpkgs. 70 - path = config.path; 70 + path = ../..; 71 71 72 72 73 73 ### Helper functions.
-14
pkgs/top-level/config.nix
··· 32 32 feature = "run <literal>checkPhase</literal> by default"; 33 33 }; 34 34 35 - path = mkOption { 36 - type = types.path; 37 - default = ../..; 38 - defaultText = lib.literalDocBook "a path expression"; 39 - internal = true; 40 - description = '' 41 - A reference to Nixpkgs' own sources. 42 - 43 - This is overridable in order to avoid copying sources unnecessarily, 44 - as a path expression that references a store path will not short-circuit 45 - to the store path itself, but copy the store path instead. 46 - ''; 47 - }; 48 - 49 35 }; 50 36 51 37 in {