Skip to content
Merged
16 changes: 8 additions & 8 deletions pkgs/stdenv/cross/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{ system, allPackages, platform, crossSystem, config, ... } @ args:
{ lib, allPackages
, system, platform, crossSystem, config
}:

rec {
argClobber = {
vanillaStdenv = (import ../. {
inherit lib allPackages system platform;
crossSystem = null;
# Ignore custom stdenvs when cross compiling for compatability
config = builtins.removeAttrs config [ "replaceStdenv" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:
This is fine, because, as the stdenv are now explicitly forced to provide a config attribute, by the fact that this commit removes the config value from top-level/default.nix. This config attribute would necessary be the config attribute given as argument to the vanillaStdenv. So there is no need to make a custom version of allPackages here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Precisely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to commit message

};
vanillaStdenv = (import ../. (args // argClobber // {
allPackages = args: allPackages (argClobber // args);
})).stdenv // {
}) // {
# Needed elsewhere as a hacky way to pass the target
cross = crossSystem;
};
Expand All @@ -17,10 +17,10 @@ rec {
# be used to build compilers and other such tools targeting the cross
# platform. Then, `forceNativeDrv` can be removed.
buildPackages = allPackages {
inherit system platform crossSystem config;
# It's OK to change the built-time dependencies
allowCustomOverrides = true;
bootStdenv = vanillaStdenv;
inherit system platform crossSystem config;
stdenv = vanillaStdenv;
};

stdenvCross = buildPackages.makeStdenvCross
Expand Down
15 changes: 10 additions & 5 deletions pkgs/stdenv/custom/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{ system, allPackages, platform, crossSystem, config, ... } @ args:
{ lib, allPackages
, system, platform, crossSystem, config
}:

assert crossSystem == null;

rec {
vanillaStdenv = (import ../. (args // {
vanillaStdenv = import ../. {
inherit lib allPackages system platform crossSystem;
# Remove config.replaceStdenv to ensure termination.
config = builtins.removeAttrs config [ "replaceStdenv" ];
})).stdenv;
};

buildPackages = allPackages {
inherit system platform crossSystem config;
# It's OK to change the built-time dependencies
allowCustomOverrides = true;
bootStdenv = vanillaStdenv;
inherit system platform crossSystem config;
stdenv = vanillaStdenv;
};

stdenvCustom = config.replaceStdenv { pkgs = buildPackages; };
Expand Down
15 changes: 8 additions & 7 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{ system ? builtins.currentSystem
, allPackages ? import ../../..
, platform ? null
, config ? {}
{ lib, allPackages
, system, platform, crossSystem, config

# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
, bootstrapFiles ? let
Expand All @@ -17,12 +15,14 @@
}
}:

assert crossSystem == null;

let
libSystemProfile = ''
(import "${./standard-sandbox.sb}")
'';
in rec {
allPackages = import ../../..;
inherit allPackages;

commonPreHook = ''
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
Expand Down Expand Up @@ -100,8 +100,9 @@ in rec {
};

thisPkgs = allPackages {
inherit system platform;
bootStdenv = thisStdenv;
inherit system platform crossSystem config;
allowCustomOverrides = false;
stdenv = thisStdenv;
};
in { stdenv = thisStdenv; pkgs = thisPkgs; };

Expand Down
8 changes: 4 additions & 4 deletions pkgs/stdenv/darwin/make-bootstrap-tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ in rec {
};

# The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
test-pkgs = let
stdenv = import (test-pkgspath + "/pkgs/stdenv/darwin") { inherit system bootstrapFiles; };
in import test-pkgspath {
test-pkgs = import test-pkgspath {
inherit system;
bootStdenv = stdenv.stdenvDarwin;
stdenv = args: let
args' = args // { inherit bootstrapFiles; };
in (import (test-pkgspath + "/pkgs/stdenv/darwin") args').stdenvDarwin;
};
}
34 changes: 18 additions & 16 deletions pkgs/stdenv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,48 @@
# 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 }:


rec {

{ # Args just for stdenvs' usage
lib, allPackages
# Args to pass on to `allPacakges` too
, system, platform, crossSystem, config
} @ args:

let
# The native (i.e., impure) build environment. This one uses the
# tools installed on the system outside of the Nix environment,
# i.e., the stuff in /bin, /usr/bin, etc. This environment should
# be used with care, since many Nix packages will not build properly
# with it (e.g., because they require GNU Make).
inherit (import ./native { inherit system allPackages config; }) stdenvNative;
inherit (import ./native args) stdenvNative;

stdenvNativePkgs = allPackages {
bootStdenv = stdenvNative;
inherit system platform crossSystem config;
allowCustomOverrides = false;
stdenv = stdenvNative;
noSysDirs = false;
};


# The Nix build environment.
stdenvNix = import ./nix {
stdenvNix = assert crossSystem == null; import ./nix {
inherit config lib;
stdenv = stdenvNative;
pkgs = stdenvNativePkgs;
};

inherit (import ./freebsd { inherit system allPackages platform config; }) stdenvFreeBSD;
inherit (import ./freebsd args) stdenvFreeBSD;

# Linux standard environment.
inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux;
inherit (import ./linux args) stdenvLinux;

inherit (import ./darwin { inherit system allPackages platform config; }) stdenvDarwin;
inherit (import ./darwin args) stdenvDarwin;

inherit (import ./cross { inherit system allPackages platform crossSystem config lib; }) stdenvCross stdenvCrossiOS;
inherit (import ./cross args) stdenvCross stdenvCrossiOS;

inherit (import ./custom { inherit system allPackages platform crossSystem config lib; }) stdenvCustom;
inherit (import ./custom args) stdenvCustom;

# Select the appropriate stdenv for the platform `system'.
stdenv =
in
if crossSystem != null then
if crossSystem.useiOSCross or false then stdenvCrossiOS
else stdenvCross else
Expand All @@ -60,5 +63,4 @@ rec {
if system == "i686-cygwin" then stdenvNative else
if system == "x86_64-cygwin" then stdenvNative else
if system == "x86_64-freebsd" then stdenvFreeBSD else
stdenvNative;
}
stdenvNative
10 changes: 5 additions & 5 deletions pkgs/stdenv/freebsd/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{ system ? builtins.currentSystem
, allPackages ? import ../../..
, platform ? null
, config ? {}
{ lib, allPackages
, system, platform, crossSystem, config
}:

assert crossSystem == null;

rec {
allPackages = import ../../..;
inherit allPackages;

bootstrapTools = derivation {
inherit system;
Expand Down
13 changes: 7 additions & 6 deletions pkgs/stdenv/linux/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
# external (non-Nix) tools, such as /usr/bin/gcc, and it contains a C
# compiler and linker that do not search in default locations,
# ensuring purity of components produced by it.
{ lib, allPackages
, system, platform, crossSystem, config

# The function defaults are for easy testing.
{ system ? builtins.currentSystem
, allPackages ? import ../../..
, platform ? null, config ? {}, lib ? (import ../../../lib)
, bootstrapFiles ?
if system == "i686-linux" then import ./bootstrap/i686.nix
else if system == "x86_64-linux" then import ./bootstrap/x86_64.nix
Expand All @@ -18,6 +16,8 @@
else abort "unsupported platform for the pure Linux stdenv"
}:

assert crossSystem == null;

rec {

commonPreHook =
Expand Down Expand Up @@ -106,8 +106,9 @@ rec {
};

thisPkgs = allPackages {
inherit system platform;
bootStdenv = thisStdenv;
inherit system platform crossSystem config;
allowCustomOverrides = false;
stdenv = thisStdenv;
};

in { stdenv = thisStdenv; pkgs = thisPkgs; };
Expand Down
7 changes: 7 additions & 0 deletions pkgs/stdenv/linux/make-bootstrap-tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ rec {

bootstrapTools = (import ./default.nix {
inherit system bootstrapFiles;

lib = assert false; null;
allPackages = assert false; null;

platform = assert false; null;
crossSystem = assert false; null;
config = assert false; null;
}).bootstrapTools;

test = derivation {
Expand Down
11 changes: 8 additions & 3 deletions pkgs/stdenv/native/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ system, allPackages ? import ../../.., config }:
{ lib, allPackages
, system, platform, crossSystem, config
}:

assert crossSystem == null;

rec {

Expand Down Expand Up @@ -126,8 +130,9 @@ rec {
} // {inherit fetchurl;};

stdenvBoot1Pkgs = allPackages {
inherit system;
bootStdenv = stdenvBoot1;
inherit system platform crossSystem config;
allowCustomOverrides = false;
stdenv = stdenvBoot1;
};


Expand Down
Loading