top-level: Remove cycles: stdenv calls in top-level but not vice versa

This commit changes the dependencies of stdenv, and clean-up the stdenv
story by removing the `defaultStdenv` attribute as well as the `bootStdenv`
parameter.

Before, the final bootstrapping stage's stdenv was provided by
all-packages, which was iterating multiple times over the
top-level/default.nix expression, and non-final bootstrapping stages'
stdenvs were explicitly specified with the `bootStdenv` parameter.

Now, all stages' stdenvs are specified with the `stdenv` parameter.
For non-final bootstrapping stages, this is a small change---basically just
rename the parameter.
For the final stage, top-level/default.nix takes the chosen stdenv and
makes the final stage with it.

`allPackages` is used to make all bootstrapping stages, final and
non-final alike. It's basically the expression of `stage.nix` (along with a
few partially-applied default arguments)

Note, the make-bootstrap-tools scripts are temporarily broken
This commit is contained in:
John Ericson 2016-11-27 12:35:58 -08:00 committed by John Ericson
parent 07a2b17cbf
commit d240a0da1a
10 changed files with 55 additions and 44 deletions

View File

@ -20,7 +20,7 @@ rec {
inherit system platform crossSystem config;
# It's OK to change the built-time dependencies
allowCustomOverrides = true;
bootStdenv = vanillaStdenv;
stdenv = vanillaStdenv;
};
stdenvCross = buildPackages.makeStdenvCross

View File

@ -10,7 +10,7 @@ rec {
inherit system platform crossSystem config;
# It's OK to change the built-time dependencies
allowCustomOverrides = true;
bootStdenv = vanillaStdenv;
stdenv = vanillaStdenv;
};
stdenvCustom = config.replaceStdenv { pkgs = buildPackages; };

View File

@ -22,7 +22,7 @@ let
(import "${./standard-sandbox.sb}")
'';
in rec {
allPackages = import ../../..;
inherit allPackages;
commonPreHook = ''
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
@ -101,7 +101,8 @@ in rec {
thisPkgs = allPackages {
inherit system platform;
bootStdenv = thisStdenv;
allowCustomOverrides = false;
stdenv = thisStdenv;
};
in { stdenv = thisStdenv; pkgs = thisPkgs; };

View File

@ -5,7 +5,7 @@
# Posix utilities, the GNU C compiler, and so on. On other systems,
# we use the native C library.
{ system, allPackages ? import ../.., platform, config, crossSystem, lib }:
{ system, allPackages ? import ../top-level, platform, config, crossSystem, lib }:
let
@ -19,7 +19,8 @@ let
inherit (import ./native { inherit system allPackages config; }) stdenvNative;
stdenvNativePkgs = allPackages {
bootStdenv = stdenvNative;
allowCustomOverrides = false;
stdenv = stdenvNative;
noSysDirs = false;
};

View File

@ -5,7 +5,7 @@
}:
rec {
allPackages = import ../../..;
inherit allPackages;
bootstrapTools = derivation {
inherit system;

View File

@ -107,7 +107,8 @@ rec {
thisPkgs = allPackages {
inherit system platform;
bootStdenv = thisStdenv;
allowCustomOverrides = false;
stdenv = thisStdenv;
};
in { stdenv = thisStdenv; pkgs = thisPkgs; };

View File

@ -127,7 +127,8 @@ rec {
stdenvBoot1Pkgs = allPackages {
inherit system;
bootStdenv = stdenvBoot1;
allowCustomOverrides = false;
stdenv = stdenvBoot1;
};

View File

@ -1,8 +1,21 @@
/* This file composes the Nix Packages collection. That is, it
imports the functions that build the various packages, and calls
them with appropriate arguments. The result is a set of all the
packages in the Nix Packages collection for some particular
platform. */
/* This function composes the Nix Packages collection. It:
1. Applies the final stage to the given `config` if it is a function
2. Infers an appropriate `platform` based on the `system` if none is
provided
3. Defaults to no non-standard config and no cross-compilation target
4. Uses the above to infer the default standard environment (stdenv) if
none is provided
5. Builds the final stage --- a fully booted package set with the chosen
stdenv
Use `impure.nix` to also infer the `system` based on the one on which
evaluation is taking place, and the configuration from environment variables
or dot-files. */
{ # The system (e.g., `i686-linux') for which to build the packages.
system
@ -12,7 +25,6 @@
, crossSystem ? null
, platform ? null
, ...
} @ args:
let # Rename the function arguments
@ -57,8 +69,15 @@ in let
# deterministically inferred the same way.
nixpkgsFun = newArgs: import ./. (args // newArgs);
pkgs = import ./stage.nix ({
inherit lib nixpkgsFun config platform;
} // args);
# Partially apply some args for building bootstraping stage pkgs sets
allPackages = newArgs: import ./stage.nix ({
inherit lib nixpkgsFun config;
} // newArgs);
stdenv = import ../stdenv {
inherit lib allPackages system platform crossSystem config;
};
pkgs = allPackages { inherit system stdenv config crossSystem platform; };
in pkgs

View File

@ -1,21 +1,24 @@
/* This file composes the Nix Packages collection. That is, it
imports the functions that build the various packages, and calls
them with appropriate arguments. The result is a set of all the
packages in the Nix Packages collection for some particular
platform. */
/* This file composes a single bootstrapping stage of the Nix Packages
collection. That is, it imports the functions that build the various
packages, and calls them with appropriate arguments. The result is a set of
all the packages in the Nix Packages collection for some particular platform
for some particular stage.
Default arguments are only provided for bootstrapping
arguments. Normal users should not import this directly but instead
import `pkgs/default.nix` or `default.nix`. */
{ # The system (e.g., `i686-linux') for which to build the packages.
system
, # The standard environment to use. Only used for bootstrapping. If
# null, the default standard environment is used.
bootStdenv ? null
, # The standard environment to use for building packages.
stdenv
, # This is used because stdenv replacement and the stdenvCross do benefit from
# the overridden configuration provided by the user, as opposed to the normal
# bootstrapping stdenvs.
allowCustomOverrides ? (bootStdenv == null)
allowCustomOverrides ? true
, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
# outside of the store. Thus, GCC, GFortran, & co. must always look for
@ -45,9 +48,7 @@ let
};
stdenvDefault = self: super:
import ./stdenv.nix {
inherit system bootStdenv crossSystem config platform lib nixpkgsFun;
};
{ stdenv = stdenv // { inherit platform; }; };
allPackages = self: super:
let res = import ./all-packages.nix
@ -81,9 +82,9 @@ let
# The complete chain of package set builders, applied from top to bottom
toFix = lib.foldl' (lib.flip lib.extends) (self: {}) [
stdenvDefault
stdenvAdapters
trivialBuilders
stdenvDefault
allPackages
aliases
stdenvOverrides

View File

@ -1,13 +0,0 @@
{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun }:
rec {
defaultStdenv = import ../stdenv {
inherit system platform config crossSystem lib;
allPackages = nixpkgsFun;
} // { inherit platform; };
stdenv =
if bootStdenv != null
then (bootStdenv // { inherit platform; })
else defaultStdenv;
}