···61 in scrubbedEval.options;
62 baseOptionsJSON =
63 let
64- filterIntoStore =
65 builtins.filterSource
66 (n: t:
67 (t == "directory" -> baseNameOf n != "tests")
68 && (t == "file" -> hasSuffix ".nix" n)
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 in
139 pkgs.runCommand "lazy-options.json" {
140- libPath = pull "lib";
141- pkgsLibPath = pull "pkgs/pkgs-lib";
142- nixosPath = pull "nixos";
143 modules = map (p: ''"${removePrefix "${modulesPath}/" (toString p)}"'') docModules.lazy;
144 } ''
145 export NIX_STORE_DIR=$TMPDIR/store
···59 inherit (cfg) config overlays localSystem crossSystem;
60 };
6162- # NOTE: flake.nix assumes that nixpkgs.config is only used with ../../..
63- # as nixpkgs.config.path should be equivalent to ../../..
64 finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;
6566in
···59 inherit (cfg) config overlays localSystem crossSystem;
60 };
610062 finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;
6364in
+1-1
pkgs/top-level/all-packages.nix
···67 clangStdenvNoLibs = mkStdenvNoLibs clangStdenv;
6869 # For convenience, allow callers to get the path to Nixpkgs.
70- path = config.path;
717273 ### Helper functions.
···67 clangStdenvNoLibs = mkStdenvNoLibs clangStdenv;
6869 # For convenience, allow callers to get the path to Nixpkgs.
70+ path = ../..;
717273 ### Helper functions.
-14
pkgs/top-level/config.nix
···32 feature = "run <literal>checkPhase</literal> by default";
33 };
3435- 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 };
5051in {