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; inherit system platform crossSystem config;
# It's OK to change the built-time dependencies # It's OK to change the built-time dependencies
allowCustomOverrides = true; allowCustomOverrides = true;
bootStdenv = vanillaStdenv; stdenv = vanillaStdenv;
}; };
stdenvCross = buildPackages.makeStdenvCross stdenvCross = buildPackages.makeStdenvCross

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,21 @@
/* This file composes the Nix Packages collection. That is, it /* This function composes the Nix Packages collection. It:
imports the functions that build the various packages, and calls
them with appropriate arguments. The result is a set of all the 1. Applies the final stage to the given `config` if it is a function
packages in the Nix Packages collection for some particular
platform. */ 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. { # The system (e.g., `i686-linux') for which to build the packages.
system system
@ -12,7 +25,6 @@
, crossSystem ? null , crossSystem ? null
, platform ? null , platform ? null
, ...
} @ args: } @ args:
let # Rename the function arguments let # Rename the function arguments
@ -57,8 +69,15 @@ in let
# deterministically inferred the same way. # deterministically inferred the same way.
nixpkgsFun = newArgs: import ./. (args // newArgs); nixpkgsFun = newArgs: import ./. (args // newArgs);
pkgs = import ./stage.nix ({ # Partially apply some args for building bootstraping stage pkgs sets
inherit lib nixpkgsFun config platform; allPackages = newArgs: import ./stage.nix ({
} // args); 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 in pkgs

View File

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